<!-- Source: @site/projects/sqlens-for-laravel/docs/rules/sec-priv-grant-option-structural.md -->
<!-- Canonical: https://docs.pushery.com/sqlens-for-laravel/rules/sec-priv-grant-option-structural/ -->

# SEC.PRIV.GRANT_OPTION_STRUCTURAL — It can hand on the power to change the schema

> Not who may read what exists — who may decide what exists.

- **Category:** security
- **Severity:** high
- **Level:** 0
- **Confidence:** deterministic
- **Downtime class:** none — the finding is about a grant, not about a statement
- **Stability:** stable
- **Suites:** audit
- **Applies to:** PostgreSQL 18 · MySQL 8.4

## Why this is a different sentence, not a worse degree

A re-grantable **data** privilege widens who can read or write what exists. A re-grantable
**structural** one widens who decides what exists at all — including who may create objects that a
later audit has no particular reason to look at twice.

That is why it is a separate rule rather than the same one at a higher severity: the two have
different fixes and belong in different places on a work list.

## Bad

```sql
-- Not just access to the data — the power to decide what exists.
GRANT CREATE ON shop.* TO 'app'@'10.0.0.%' WITH GRANT OPTION;
```

## Good

```sql
-- Structural rights stay with the account that deploys migrations…
GRANT CREATE ON shop.* TO 'deploy'@'10.0.0.%';

-- …and the application account keeps only what it uses at run time.
GRANT SELECT, INSERT, UPDATE, DELETE ON shop.* TO 'app'@'10.0.0.%';
```

## The legitimate case, and why the fix costs nothing anyway

A migration or deployment account holding structural rights is common and usually deliberate — it is
the account whose job is to change the schema. An **application** account holding them is almost
never intended.

Either way, revoking only the grant option takes back the ability to hand the privilege on and
nothing else: `REVOKE GRANT OPTION ON …` on MySQL, `REVOKE GRANT OPTION FOR … ON …` on PostgreSQL. The
account keeps working exactly as it did, which means this finding can be acted on even where the
underlying grant is correct.

## How "structural" is decided

From the reading's own classification of the privilege, not re-derived here. That matters for
consistency rather than for tidiness: other rules already use the same flag, so one grant cannot be
structural to this rule and ordinary to another.

## What is not reported

The same exclusions as its sibling: a grant the engine ships, and a grant that could not be read in
full — the latter as `undetermined`, never as a clean bill.

## Related

- [`SEC.PRIV.GRANT_OPTION`](https://docs.pushery.com/sqlens-for-laravel/rules/sec-priv-grant-option.md) — the same clause on a data privilege.
- [`SEC.PRIV.RUNTIME_DDL`](https://docs.pushery.com/sqlens-for-laravel/rules/sec-priv-runtime-ddl.md) — the runtime connection holding schema-changing
  rights at all, which is the question one step before this one.
