Skip to content

fix(server): default dynamodb:Select, ReturnValues and ReturnConsumedCapacity condition keys - #738

Open
LeeroyHannigan wants to merge 25 commits into
mainfrom
fix/717-condition-key-defaults
Open

LeeroyHannigan wants to merge 25 commits into
mainfrom
fix/717-condition-key-defaults

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

dynamodb:Select, dynamodb:ReturnValues and dynamodb:ReturnConsumedCapacity now hold the value the operation uses when the request omits the parameter. This holds on single-table requests, on each table of a batch and on each transaction item. Before this change the three keys were read from the request's own Select, ReturnValues and ReturnConsumedCapacity alone, and only on requests with a single authorization target. A request that omitted the parameter left the key absent, and the batch and transaction targets never carried the keys.

Key Requests Value when the request has no such parameter
dynamodb:Select GetItem, Query and Scan, each table of a BatchGetItem, each Get of a TransactGetItems SPECIFIC_ATTRIBUTES with a ProjectionExpression or AttributesToGet, ALL_ATTRIBUTES without one
dynamodb:Select A Query or Scan with IndexName and no projection ALL_PROJECTED_ATTRIBUTES
dynamodb:ReturnValues PutItem, UpdateItem and DeleteItem, and the Put, Update and Delete items of a TransactWriteItems NONE
dynamodb:ReturnConsumedCapacity GetItem, PutItem, UpdateItem, DeleteItem, Query and Scan, and each table or item of a BatchGetItem, BatchWriteItem, TransactGetItems or TransactWriteItems NONE

A Query or Scan that carries Select holds it as given. A BatchWriteItem and a ConditionCheck leave dynamodb:ReturnValues absent, as before.

Changes:

  • New crates/server/src/parameter_keys.rs builds the three values for a single-table request, for one table of a batch and for one transaction item. Both authorization branches in request_helpers.rs take the values from it.
  • AuthzTarget in crates/server/src/leading_keys/batch.rs carries the values. Transaction items that give the same target are still evaluated once. On a table with a sort key, take a Get that projects pk and a Get of another item in the same partition that projects nothing. Both hold the same dynamodb:LeadingKeys and dynamodb:Attributes. They now give two targets, so the second Get is evaluated with ALL_ATTRIBUTES.
  • GetItem, BatchGetItem and TransactGetItems take no Select parameter, so their dynamodb:Select comes from the projection alone. Before this change a Select member in a GetItem was copied into the key. The engine ignores that member, so with the member copied, a GetItem with "Select": "SPECIFIC_ATTRIBUTES" and no projection would pass a Deny on ALL_ATTRIBUTES and return the whole item.
  • Every single-table request now follows the rule of the batch and transaction targets. A key is set only on the operations that take its parameter. Before this change a member the operation does not take still set the key, for example a Select on a PutItem, DeleteItem or DeleteTable, or a ReturnValues on a GetItem, Query or Scan. An Allow of a broad action gated only on such a key then granted the request once the member was added to it. Control-plane requests carry none of the three keys.
  • A null ProjectionExpression, AttributesToGet or Select reads as absent, as the engine does, so the key falls to the default. The engine refuses a null ReturnValues or ReturnConsumedCapacity with a SerializationException, so such a request never reaches authorization.
  • The security model manual describes the values, and the upgrade manual has an entry for the policy shapes that now decide differently.

The branch started from the head of #732, which merged on 2026-11-11, and has origin/main merged in.

Why

With the key absent, IAM's rules for a missing key decided these statements differently from DynamoDB:

Statement Request DynamoDB ExtendDB before
Deny GetItem with StringNotEqualsIfExists {"dynamodb:Select": "SPECIFIC_ATTRIBUTES"} GetItem with a projection allowed AccessDeniedException
Deny GetItem, Query and Scan with StringEquals {"dynamodb:Select": "ALL_ATTRIBUTES"} a read with no projection AccessDeniedException allowed, whole items returned
Allow PutItem only with StringEquals {"dynamodb:ReturnValues": "NONE"} PutItem without ReturnValues allowed AccessDeniedException

The second row let a whole-item read through a Deny that DynamoDB enforces. The same gap has an Allow side. The Developer Guide's Example 3 is an allowlist that grants reads gated on StringEqualsIfExists {"dynamodb:Select": "SPECIFIC_ATTRIBUTES"}. It granted a read with no projection, because the absent key satisfied the IfExists. That read returns the whole item, attributes outside the allowlist included. After this change the key holds ALL_ATTRIBUTES on such a read and the allowlist refuses it.

Closes #717

Measured on DynamoDB in us-east-1 on 2026-11-01, with each policy below as a session policy. Every request was sent twice and got the same answer both times. The policies:

  • deny-unless-specific(A): Allow dynamodb:* on the table, and Deny the actions A with StringNotEqualsIfExists {"dynamodb:Select": "SPECIFIC_ATTRIBUTES"}.
  • deny-all(A): Allow dynamodb:* on the table, and Deny the actions A with StringEquals {"dynamodb:Select": "ALL_ATTRIBUTES"}.
  • allow-only A RV=NONE: the only statement allows A with StringEquals {"dynamodb:ReturnValues": "NONE"}. RCC=NONE is the same over dynamodb:ReturnConsumedCapacity, and Select=SPECIFIC over dynamodb:Select with SPECIFIC_ATTRIBUTES.

The "ExtendDB before" column is the answer of a build of #732's head.

Request Policy DynamoDB ExtendDB before
GetItem ProjectionExpression #n deny-unless-specific(GetItem) allowed AccessDeniedException
GetItem, no projection deny-unless-specific(GetItem) AccessDeniedException AccessDeniedException
Query ProjectionExpression #n deny-unless-specific(Query) allowed AccessDeniedException
Query, no projection deny-unless-specific(Query) AccessDeniedException AccessDeniedException
GetItem, no projection deny-all(GetItem, Query, Scan) AccessDeniedException allowed
GetItem ProjectionExpression #n deny-all(GetItem, Query, Scan) allowed allowed
Query, no projection deny-all(GetItem, Query, Scan) AccessDeniedException allowed
Scan, no projection deny-all(GetItem, Query, Scan) AccessDeniedException allowed
Scan Select COUNT deny-all(GetItem, Query, Scan) allowed allowed
Query Select COUNT deny-all(Query) allowed allowed
BatchGetItem, no projection deny-all(BatchGetItem) AccessDeniedException allowed
BatchGetItem ProjectionExpression #n deny-all(BatchGetItem) allowed allowed
BatchGetItem ProjectionExpression #n allow-only BatchGetItem Select=SPECIFIC allowed AccessDeniedException
TransactGetItems Get, no projection deny-all(GetItem) AccessDeniedException allowed
TransactGetItems Get ProjectionExpression #n deny-all(GetItem) allowed allowed
PutItem without ReturnValues allow-only PutItem RV=NONE allowed AccessDeniedException
PutItem ReturnValues ALL_OLD allow-only PutItem RV=NONE AccessDeniedException AccessDeniedException
UpdateItem without ReturnValues allow-only UpdateItem RV=NONE allowed AccessDeniedException
UpdateItem ReturnValues ALL_NEW allow-only UpdateItem RV=NONE AccessDeniedException AccessDeniedException
DeleteItem without ReturnValues allow-only DeleteItem RV=NONE allowed AccessDeniedException
DeleteItem ReturnValues ALL_OLD allow-only DeleteItem RV=NONE AccessDeniedException AccessDeniedException
BatchWriteItem with one PutRequest allow-only BatchWriteItem RV=NONE AccessDeniedException AccessDeniedException
TransactWriteItems with one Update allow-only UpdateItem RV=NONE allowed AccessDeniedException
TransactWriteItems with one Put allow-only PutItem RV=NONE allowed AccessDeniedException
TransactWriteItems with one Delete allow-only DeleteItem RV=NONE allowed AccessDeniedException
GetItem without ReturnConsumedCapacity allow-only GetItem RCC=NONE allowed AccessDeniedException
GetItem ReturnConsumedCapacity TOTAL allow-only GetItem RCC=NONE AccessDeniedException AccessDeniedException
BatchWriteItem with one PutRequest, no ReturnConsumedCapacity allow-only BatchWriteItem RCC=NONE allowed AccessDeniedException
TransactGetItems with one Get, no ReturnConsumedCapacity allow-only GetItem RCC=NONE allowed AccessDeniedException

These were not measured, and the code, tests and docs say so:

  • ALL_PROJECTED_ATTRIBUTES on a Query or Scan of an index with no projection and no Select. The DynamoDB API reference for Query gives it as the default when neither Select nor ProjectionExpression is given on a read of an index.
  • dynamodb:ReturnConsumedCapacity on PutItem, UpdateItem, DeleteItem, Query, Scan, BatchGetItem and the items of a TransactWriteItems, which follows the measured rows.
  • AttributesToGet as a projection for dynamodb:Select, which follows the ProjectionExpression rows. The engine reads AttributesToGet as a projection.
  • Two Gets of one partition in a TransactGetItems that differ only in their projection, which follows the TransactGetItems rows.

Testing done

  • tests/test_dynamodb_condition_key_defaults.py is a new file of 31 wire tests: one per measured row (29) and one for each of the two unmeasured transaction and index shapes. Each attaches the row's policy as a user policy. It asserts DynamoDB's answer, the action named in a refusal, and that a refused write leaves the table unchanged. At 551d76c, on SQLite, it passes (31 passed) and so do the three tests/test_dynamodb_attributes_*.py files (99 passed). The file (31 tests) and the three attributes files of that time (84) also passed on PostgreSQL (pgvector/pgvector:pg16). That run was at 59fc193, the first commit of the fix.
  • The 16 authorization wire files fix: populate dynamodb:Attributes for every item request #732 lists ran on SQLite against a server built from 551d76c: 459 passed, 8 skipped. The skipped tests are tests/test_dev_mode_authorization.py, which needs a dev-mode build. Each test ran with its own test credentials, as devtools/run-tests provisions them.
  • Against a build of fix: populate dynamodb:Attributes for every item request #732's head (2a821f94e) on SQLite, the new file fails 19 tests and passes 12. The 19 are the 17 measured rows whose "ExtendDB before" differs from DynamoDB, and the two unmeasured shapes. Every row of the first table is among the 17.
  • 16 unit tests in crates/server/src/parameter_keys/tests.rs cover each default, a given value winning over it, null members, and the Select member of a GetItem and of a BatchGetItem table. They also cover keys an operation does not take, operations that get no default, and the batch and transaction targets.
  • Negative controls, each made on the committed tree and reverted with git afterwards:
    • With no GetItem default, 3 unit tests fail, and on SQLite the two GetItem wire tests of the first table fail (2 of 31).
    • With ALL_ATTRIBUTES in place of ALL_PROJECTED_ATTRIBUTES for an index read, 1 unit test and the index wire test fail (1 of 31).
    • With the transaction dedup ignoring the three values, 1 unit test and the two-Get wire test fail (1 of 31).
    • With no ReturnValues on transaction items, 2 unit tests and the three transaction write wire tests fail (3 of 31).
    • With a null projection counted as a projection, 1 unit test fails.
    • With no ReturnConsumedCapacity default on single-table requests, 1 unit test fails.
    • With a Select member read on PutItem, UpdateItem and DeleteItem, 1 unit test fails. The same holds with a ReturnValues member read on GetItem, Query and Scan, and with the three members read on a control-plane request.
  • At 551d76c, on 1.97.0 (the toolchain of the fmt and clippy CI jobs): cargo fmt --all -- --check passes, and cargo clippy --locked -p extenddb-server -p extenddb-auth --all-targets -- -D warnings gives no warning.
  • At 551d76c, cargo check --locked -p extenddb-server -p extenddb-auth --all-targets passes on 1.91.1, the rust-version of Cargo.toml. The test CI job runs on stable and on 1.91.1.
  • At 551d76c, cargo test --locked -p extenddb-server -p extenddb-auth on stable (1.99.0) and on 1.91.1 gives the same counts. The server crate runs 535 unit tests and no doc tests. The auth crate runs 533 unit tests, 14 integration tests (sigv4_differential) and 3 doc tests. 530 of the 535 server tests pass. The 5 that fail are backup_store tests. They create a spool or a backup root under the temp directory. The owner check needs every ancestor of that directory owned by root or by the user that runs the tests. On the host that ran them, /local/home is owned by uid 65534, so the check refuses the directory. The 5 tests do not touch this PR's code. At fe9923a, the pushed head, the Test CI job passed on stable and on 1.91.1 on 2026-11-19, so the 5 pass on CI's runner.

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, or public CLI surface, an RFC has been accepted or is linked
    below. Otherwise, an ADR captures the decision (link below).

ADR / RFC: n/a. The three condition keys now hold the values DynamoDB gives them. The policy language and evaluator are unchanged.

Breaking changes

Policies that name dynamodb:Select, dynamodb:ReturnValues or dynamodb:ReturnConsumedCapacity can decide differently after this change (recorded in the upgrade manual under v1.1.0):

  • A Deny gated on StringEquals with dynamodb:Select ALL_ATTRIBUTES now refuses a GetItem, Query or Scan with no projection and no Select, a BatchGetItem table with no projection, and a TransactGetItems Get with no projection. It does not refuse a Query or Scan of an index with no projection, which holds ALL_PROJECTED_ATTRIBUTES.

  • A Deny gated on StringNotEquals or StringNotEqualsIfExists with dynamodb:Select SPECIFIC_ATTRIBUTES stops refusing reads that project, and still refuses reads without a projection.

  • An Allow gated on StringEquals with dynamodb:Select SPECIFIC_ATTRIBUTES now grants a read that projects without Select. It no longer grants a GetItem with no projection that carries a Select member of that value.

  • An Allow gated on StringEquals with dynamodb:ReturnValues NONE now grants a PutItem, UpdateItem or DeleteItem without ReturnValues, and the Put, Update and Delete items of a TransactWriteItems. It still refuses a BatchWriteItem.

  • An Allow gated on StringEquals with dynamodb:ReturnConsumedCapacity NONE now grants the item, batch and transaction requests its Action covers that carry no ReturnConsumedCapacity.

  • A Deny gated on StringNotEquals or StringNotEqualsIfExists with dynamodb:ReturnValues NONE stops refusing a PutItem, UpdateItem, DeleteItem or transaction write item that omits it. It still refuses a BatchWriteItem and a ConditionCheck. The same shape over dynamodb:ReturnConsumedCapacity NONE stops refusing the GetItem, PutItem, UpdateItem, DeleteItem, Query, Scan and the tables and items of a batch or transaction that omit it. It still refuses a SearchVectors that omits it.

  • Null with value true on one of the three keys no longer matches the requests that now hold the key. For dynamodb:Select those are a GetItem, Query, Scan, BatchGetItem or TransactGetItems. For dynamodb:ReturnValues they are a PutItem, UpdateItem, DeleteItem or transaction write item. For dynamodb:ReturnConsumedCapacity they are the item, batch and transaction requests. It still matches a BatchWriteItem and a ConditionCheck for dynamodb:ReturnValues and a SearchVectors for dynamodb:ReturnConsumedCapacity, which leave the key absent. Null with value false now matches the requests that hold the key.

  • An Allow gated on StringEqualsIfExists with dynamodb:Select SPECIFIC_ATTRIBUTES, the Developer Guide's Example 3, granted every GetItem, BatchGetItem and TransactGetItems its Action covered and every Query or Scan without Select, because the absent key satisfied the IfExists. It now grants only reads that project, and refuses a read with no projection, which returns the whole item. Check any policy copied from Example 3.

  • An Allow gated on StringEquals with dynamodb:Select ALL_PROJECTED_ATTRIBUTES, the Developer Guide's Example 5 second policy, now grants a Query or Scan of an index with no projection and no Select. Before, it refused that read. This depends on the index default, which follows the API reference and was not measured.

  • A statement gated on one of the three keys no longer matches a request whose operation does not take that parameter. A member of that name in the request does not change this. Before this change an Allow of a broad action gated on dynamodb:Select granted a PutItem or a DeleteTable that carried a matching Select member.

An IfExists or negated condition that the absent key satisfied is now evaluated against the default value. A positive condition on a default value (ALL_ATTRIBUTES, ALL_PROJECTED_ATTRIBUTES or NONE) now matches the requests that hold it.

Not covered

  • SearchVectors takes ReturnConsumedCapacity and neither Select nor ReturnValues. Its dynamodb:ReturnConsumedCapacity holds the parameter when the request carries it and is absent otherwise, as before. The service authorization reference lists no condition keys for the SearchVectors action, and whether DynamoDB evaluates this key on it at all was not measured.

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.

…to a submodule

leading_keys.rs is 601 lines. Move AuthzTarget, batch_transact_targets,
batch_transact_tables and batch_table_keys unchanged into
leading_keys/batch.rs, and re-export the two functions that request
authorization calls.
The dynamodb:Attributes condition key was read from ProjectionExpression
alone, only on single-table requests, and a document path such as secret.a
went into it as written. Writes, AttributesToGet reads and every batch and
transaction request reached the policy evaluator without the key, so a Deny
gated on ForAnyValue:StringEquals over an attribute never applied to them,
and an Allow gated on ForAllValues:StringEquals granted them whatever
attributes they wrote or read.

The key now holds the top-level names a request names: the item or key
attributes, AttributesToGet, the paths in the projection, update, condition
and filter expressions with ExpressionAttributeNames resolved, the legacy
Expected, AttributeUpdates, QueryFilter and ScanFilter maps,
ExclusiveStartKey, and the key attributes of the table and of a queried
index. A batch request carries the names per table and a transaction per
item. A DeleteItem and a read with no projection hold only the names the
request gives, not those of the stored item.
…ansaction requests

One test per request shape measured on DynamoDB on 2026-10-31, under a user
policy of the shape of the session policy each was measured with: a Deny
gated on ForAnyValue:StringEquals over one attribute, and an Allow of
PutItem gated on ForAllValues:StringEquals over pk. Each asserts the
service's answer, the action the refusal names, and that a refused write
stores nothing.
The security model manual lists the names the key holds for each item,
batch and transaction operation, and which entries were measured on
DynamoDB. The troubleshooting entry for an Attributes condition covers a
Deny that does not block a DeleteItem or a read with no projection, and an
allowlist that omits the key attributes. The upgrade manual records the
change for v0.1.15 and the policy statements it affects.
Rename the ExpressionAttributeNames field so it no longer repeats the
struct name, merge the match arms that walk two operands, and replace
for_each with loops. Behaviour is unchanged.
…utes

DynamoDB authorizes an UpdateItem whose only mention of an attribute is in
a SET value. Under a Deny gated on ForAnyValue:StringEquals over ssn, it
authorized SET #n = ssn, SET #n = if_not_exists(ssn, :d),
list_append(ssn, :l) and ssn + :one, and refused REMOVE ssn, ADD ssn :one
and DELETE ssn :s (measured 2026-11-01). The key for an UpdateItem and for
a transaction's Update item now holds the attribute each action names, and
no longer the paths its value reads.
…ns and key attributes

One test per request shape measured on DynamoDB on 2026-11-01: a condition,
filter, Expected, AttributeUpdates or ScanFilter that reads a denied
attribute, a REMOVE, ADD or DELETE of it, and a ConditionCheck on it are
refused; a SET value that reads it is authorized and copies it; a bare
StringNotEquals grants no Scan; a Null condition does not refuse a GetItem
with no projection; and an allowlist without the table's key attribute
refuses a projected GetItem. The new module reuses the fixtures of
test_dynamodb_attributes_condition.py.
The security model manual, the troubleshooting guide and the upgrade
manual now say that the key holds the target of each UpdateExpression
action and not the attributes a SET value reads, and that, as in DynamoDB,
a policy on dynamodb:Attributes does not stop an UpdateItem from copying a
denied attribute's value into another attribute through a SET value. The
security model manual lists the entries measured on DynamoDB on 2026-10-31
and 2026-11-01, and records that a bare StringNotEquals on the key matches
neither a present nor an absent key.
…n Scan

A Scan now puts the key attributes of the table, and with IndexName the key
attributes of that index, in dynamodb:Attributes, as GetItem and Query do.
Before this change a Scan that named no attribute left the key absent.

DynamoDB, measured on 2026-11-01: a Deny over pk refuses a Scan with no
projection. An Allow of Scan alone with ForAllValues:StringEquals over
["name"] refuses a plain, a projected and a Select COUNT Scan; the same Allow
over ["pk", "name"] admits the projected Scan, and over ["pk"] it admits a
plain Scan. A Deny of Scan gated on Null {"dynamodb:Attributes": "true"}
refuses neither a plain nor a projected Scan, and an Allow of Scan alone on
the same Null grants neither a plain nor a Select COUNT Scan.

With the key absent, ExtendDB used to give the opposite answer to each
plain and Select COUNT Scan here except the one under ["pk"]; it also
granted the projected Scan under ["name"], whose key held name alone.

The index key attributes follow the IAM guide's rule that a policy on
dynamodb:Attributes lists the key attributes of the table and of every index
it covers. They were not measured.
Wire tests for rows DynamoDB answered on 2026-11-01 that had none: a Deny
over pk, Allows over ForAllValues lists, and Null in a Deny and an Allow, on
Scan; the table's key attribute on Query, UpdateItem, DeleteItem and a
BatchWriteItem DeleteRequest; QueryFilter, AttributesToGet on Query and
BatchGetItem, and the Update and Delete items of TransactWriteItems under a
Deny on ssn; and ReturnValues ALL_OLD and ReturnValuesOnConditionCheckFailure
ALL_OLD, which return the stored item with the denied attribute in it.

An Allow of BatchWriteItem alone with ForAnyValue:StringEquals over ["name"]
admits a batch that puts {pk, name} and {pk, ssn} on one table and writes
both items, admits {pk, name} alone, and refuses {pk, ssn} alone. The service
evaluates each table's part of the batch once, with the names of all its
items, and ExtendDB does the same.

Two rows were not measured, and their docstrings say so: a PutItem with
ReturnValues ALL_OLD follows the UpdateItem row, and a Query on a global
secondary index follows the IAM guide's rule that a policy on the key lists
the key attributes of the table and of every index it covers.
…hapes

The security model, the upgrade entry, the troubleshooting guide and the
policy evaluator's comments now say that a Scan holds the table's key
attributes. On a table that exists the key is absent only on a
SearchVectors with no ProjectionExpression. On a table that does not exist
it is also absent on a GetItem or transaction Get that names no attribute
outside its Key, a Query that names none outside its key condition and a
Scan that names none, because the extractor reads no Key on a GetItem or a
Get and no key condition on a Query. The rows DynamoDB answered on
2026-11-01 are labelled measured; the index key attributes and the names
of ExclusiveStartKey are labelled unmeasured.

The upgrade entry opens its list with the rule the shapes follow: every
item request other than SearchVectors now carries the key, holding at
least the table's key attributes, so a ForAllValues condition no longer
holds vacuously, a ForAnyValue condition can match, Null true stops
matching and Null false starts matching. Its bullets cover a Deny gated on
a ForAnyValue string operator; a Deny gated on a negated one, which now
needs the key attributes in its list; an Allow gated on ForAllValues; an
Allow gated on ForAnyValue over any listed attribute, with the per-table
BatchWriteItem union as its example; the negated Allow shapes; and Null
with either value.

The security model says that a Deny on the key does not stop ReturnValues
ALL_OLD or ReturnValuesOnConditionCheckFailure ALL_OLD from returning the
whole stored item, as on DynamoDB, and that the IAM guide's guard against
ReturnValues returning attributes is a condition on dynamodb:ReturnValues.
The extractor's module docs say that ReturnValues and
ReturnValuesOnConditionCheckFailure were measured to add no names and that
Select was not measured. The unit test module docs say which unmeasured
rows follow the IAM guide's rule and which follow the rule measured for the
same parameter on another operation.
…Capacity

ExtendDB set dynamodb:Select, dynamodb:ReturnValues and
dynamodb:ReturnConsumedCapacity only from the request's own parameters,
and only on requests with a single authorization target. When a request
left the parameter out, the key was absent, and the batch and transaction
targets never carried the keys. DynamoDB evaluates the value the operation
uses instead (measured 2026-11-01):

- dynamodb:Select is SPECIFIC_ATTRIBUTES on a GetItem, Query or Scan with
  a projection and ALL_ATTRIBUTES on one without, and the same on each
  table of a BatchGetItem and on each Get of a TransactGetItems. A Query
  or Scan with a Select holds it as given.
- dynamodb:ReturnValues is NONE on a PutItem, UpdateItem or DeleteItem
  without ReturnValues, and on the Put, Update and Delete items of a
  TransactWriteItems. A BatchWriteItem leaves the key absent.
- dynamodb:ReturnConsumedCapacity is NONE on a GetItem, a BatchWriteItem
  and the Get of a TransactGetItems without ReturnConsumedCapacity.

With the key absent, a Deny on Select ALL_ATTRIBUTES did not refuse a read
with no projection, which returns the whole item, and an Allow gated on
ReturnValues NONE refused writes that DynamoDB grants.

The parameter_keys module holds these values for a single-table request,
for each table of a batch and for each transaction item, and the batch and
transaction targets carry them, so two Gets of one partition that differ
only in their projection are evaluated apart. A Query or Scan of an index
with no projection and no Select holds ALL_PROJECTED_ATTRIBUTES, the
default the DynamoDB API reference gives for a read of an index; that was
not measured. dynamodb:ReturnConsumedCapacity defaults to NONE on the other
item operations as on the measured ones. GetItem, BatchGetItem and
TransactGetItems take no Select parameter, so a Select member in them no
longer decides the key: the engine ignores the member and returns the
whole item when nothing is projected.
Wire tests for the rows DynamoDB answered on 2026-11-01 for
dynamodb:Select, dynamodb:ReturnValues and dynamodb:ReturnConsumedCapacity
on requests that leave the parameter out:

- A Deny of GetItem or Query with StringNotEqualsIfExists over
  SPECIFIC_ATTRIBUTES lets a read with a projection through and refuses
  one without.
- A Deny of GetItem, Query and Scan with StringEquals over ALL_ATTRIBUTES
  refuses a read with no projection and lets a projected GetItem and a
  Select COUNT Scan or Query through. The same holds for each table of a
  BatchGetItem and for the Get of a TransactGetItems, and an Allow of
  BatchGetItem gated on SPECIFIC_ATTRIBUTES grants a projected one.
- An Allow gated on ReturnValues NONE grants a PutItem, UpdateItem or
  DeleteItem without ReturnValues and the Put, Update and Delete items of
  a TransactWriteItems, refuses the single-item writes that ask for
  ALL_OLD or ALL_NEW, and refuses a BatchWriteItem.
- An Allow gated on ReturnConsumedCapacity NONE grants a GetItem, a
  BatchWriteItem and a TransactGetItems without ReturnConsumedCapacity,
  and refuses a GetItem that asks for TOTAL.

Each refused write is checked to leave the table unchanged.

Two rows were not measured, and their docstrings say so. A Query of a
global secondary index with no projection and no Select holds
ALL_PROJECTED_ATTRIBUTES, as the API reference gives for a read of an
index, so a Deny on ALL_PROJECTED_ATTRIBUTES refuses it and a Deny on
ALL_ATTRIBUTES does not. Two Gets of one partition in a TransactGetItems
that differ only in their projection are evaluated apart, following the
measured TransactGetItems rows.
…faults

The security model's condition key table and a new section say which
value dynamodb:Select, dynamodb:ReturnValues and
dynamodb:ReturnConsumedCapacity hold when a request leaves the parameter
out, on single-table requests and on each table of a batch and each
transaction item, and which rows DynamoDB answered on 2026-11-01. The
section says that a Query or Scan of an index with no projection holds
ALL_PROJECTED_ATTRIBUTES, following the API reference, so a statement
meant to refuse whole-item reads of a table and its indexes lists both
ALL_ATTRIBUTES and ALL_PROJECTED_ATTRIBUTES. The paragraph on ReturnValues
ALL_OLD no longer says that ExtendDB sets dynamodb:ReturnValues only when
the request carries ReturnValues.

The upgrade manual's new entry lists the policy shapes that now decide
differently: a Deny on Select ALL_ATTRIBUTES now refuses reads with no
projection; a Deny gated on StringNotEqualsIfExists over Select
SPECIFIC_ATTRIBUTES stops refusing projected reads; an Allow gated on
Select SPECIFIC_ATTRIBUTES, ReturnValues NONE or ReturnConsumedCapacity
NONE now grants the requests that omit the parameter; a Deny gated on
StringNotEqualsIfExists over ReturnValues or ReturnConsumedCapacity NONE
stops refusing them; and Null on the three keys no longer matches them.
Documentation and comment edits for the dynamodb:Select, dynamodb:ReturnValues
and dynamodb:ReturnConsumedCapacity defaults. No behaviour changes: single_table,
batch_table and transact_item are untouched and no service measurement was added.

Security model and upgrade manual:

- Label every stated-but-unmeasured row as not measured: a Scan with a
  projection, a TransactGetItems Get with a projection, a ConditionCheck leaving
  dynamodb:ReturnValues absent, AttributesToGet read as a projection, and
  dynamodb:ReturnConsumedCapacity on the operations beyond those measured.
- Correct the condition key table so the dynamodb:ReturnValues and
  dynamodb:ReturnConsumedCapacity rows name the requests that hold each default
  rather than every write or item request.
- Scope the StringNotEquals and Null breaking-change bullets to the requests that
  now hold each key, and note that GetItem, BatchGetItem and TransactGetItems hold
  dynamodb:Select though they take no Select parameter, while BatchWriteItem,
  ConditionCheck and SearchVectors still leave their key absent.
- Add the breaking-change shapes the entry had missed: an Allow gated on
  StringEqualsIfExists over dynamodb:Select SPECIFIC_ATTRIBUTES, which matches the
  Developer Guide's Example 3; an Allow gated on StringEquals over
  dynamodb:Select ALL_PROJECTED_ATTRIBUTES, which matches Example 5; and the bare
  negated operator forms alongside the IfExists forms. State the general rule that
  a condition the absent key satisfied is now evaluated against the default value.
- Note that dynamodb:ReturnValues reflects the ReturnValues parameter alone and
  not ReturnValuesOnConditionCheckFailure, so an Allow gated on NONE grants a
  write whose failed condition can still return the stored item.

parameter_keys.rs:

- The module doc no longer describes a key the operation does not take holding a
  stray request member.
- The given doc states that a null Select or projection member reads as absent,
  while the engine refuses a null ReturnValues or ReturnConsumedCapacity.
- parameter_keys/tests.rs comments the null ReturnValues case as the default path.
single_table seeded dynamodb:Select, dynamodb:ReturnValues and
dynamodb:ReturnConsumedCapacity from the request body for every
operation and then adjusted them per operation, so an operation that
does not take a parameter still carried a member of that name from the
body. A policy that grants a broad action gated only on such a key could
then be satisfied by adding that member to a request the operation does
not model: a Select on a write or a control-plane call, a ReturnValues
on a read.

Build the keys per operation, the rule batch_table and transact_item
already follow: Select on GetItem, Query and Scan; ReturnValues on
PutItem, UpdateItem and DeleteItem; ReturnConsumedCapacity on the
operations that report it; none on a control-plane operation.
SearchVectors keeps its ReturnConsumedCapacity, read as given. The
measured per-operation defaults do not change; two unit tests that
pinned the old copying behaviour now assert the key is absent.
This branch started from the first commits of #732. Main holds the final form of #732 as 5804374, with later changes on top. The conflicted files that this branch changed only through those first commits come from main unchanged.

crates/auth/src/policy/condition.rs comes from main.

crates/auth/src/policy/condition/tests/multivalued.rs comes from main.

crates/auth/src/policy/context.rs comes from main.

crates/server/src/request_attributes.rs comes from main.

crates/server/src/request_attributes/tests.rs comes from main.

docs/troubleshooting.md comes from main.

tests/test_dynamodb_attributes_key_attributes.py comes from main.

crates/server/src/leading_keys/batch.rs keeps the parameters field of AuthzTarget from this branch, set on each batch table and each transaction item. Main's copy equals the one this branch started from.

crates/server/src/lib.rs keeps the registration and repeated_headers modules from main and adds parameter_keys from this branch.

crates/server/src/request_helpers.rs keeps the authorization steps from main. In them, each batch table, each transaction item and each single-table request takes its dynamodb:Select, dynamodb:ReturnValues and dynamodb:ReturnConsumedCapacity values from parameter_keys, as on this branch.

docs/manuals/10-security-model.md keeps the Query, Scan and BatchGetItem rows and the dynamodb:Attributes paragraphs from main. It keeps the condition key rows, the ReturnValues paragraph and the section on default values from this branch.
Main's tests in crates/server/src/request_helpers.rs call json! in seven places and import it in the tests module. The first #732 commits on this branch removed every json! call from the tests and the import with them. The merge kept that removal and main's calls, so the tests module had no json! in scope. This commit restores the import as main has it.
Main holds the final #732 text of the upgrade manual entry on dynamodb:Attributes, ahead of the console metrics and StreamArn entries. This branch carried the first #732 text of the same entry after the StreamArn entry. The merge kept both copies. They sit at different lines, so they did not conflict. This commit removes the copy from this branch, and the entry for the dynamodb:Select, dynamodb:ReturnValues and dynamodb:ReturnConsumedCapacity values now follows the StreamArn entry.
No file conflicted. The merge brings main at version 1.0.0 (#1107), and the next commit gives the upgrade entry of this branch that release.
Release 0.1.15 shipped without this branch, and main (#1107) now carries version 1.0.0. The upgrade manual entry of this branch on the dynamodb:Select, dynamodb:ReturnValues and dynamodb:ReturnConsumedCapacity defaults said v0.1.15, so its heading now says v1.0.0.
Release 1.0.0 shipped without this branch. The upgrade manual entry of this branch on the dynamodb:Select, dynamodb:ReturnValues and dynamodb:ReturnConsumedCapacity defaults said v1.0.0, so its heading now says v1.1.0.

@LJMart11 LJMart11 left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at fe9923a. Server tests passed (534 tests). One upgrade-manual ordering finding is left inline. The PR testing section also needs Rust 1.91.1 and the current server/auth test counts.

Comment thread docs/manuals/07-upgrade-manual.md Outdated

DescribeStream and GetShardIterator now refuse a client-built `StreamArn` with the `arn:aws-cn:` or `arn:aws-us-gov:` partition with `ValidationException` "Invalid StreamArn", also on a deployment whose `server.region` is a China or GovCloud region. The server issues every stream ARN as `arn:aws:`, so a `StreamArn` taken from DescribeTable or ListStreams is not affected. No catalog migration is required.

### v1.1.0: `dynamodb:Select`, `dynamodb:ReturnValues` and `dynamodb:ReturnConsumedCapacity` hold a value when the request omits the parameter

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the v1.1.0 entry before the older release entries in the upgrade manual. Behavior Changes by Release lists newest first, but this entry is at line 1220 after the v0.1.15 section that starts at line 413. Because the entry documents policy-shape changes, operators upgrading from 1.0.0 could stop in the older section before reaching it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved in 551d76c. The entry now follows the v1.1.0 entry of #398 at the top of Behavior Changes by Release, before the two v1.0.0 entries. Its text did not change. The v0.1.15 entries that came before it at fe9923a now come after it.

No file conflicted. Of the files this branch changes, main changed only docs/manuals/07-upgrade-manual.md. #1133 rewrote four sentences of the 1.0.0 notes. #526 added a v1.1.0 entry at the end of Behavior Changes by Release.
Main gained six merged PRs after the previous merge commit. No file conflicted. Of the files this branch changes, main changed two. #544 adds a Query request check to authorize_request in crates/server/src/request_helpers.rs, before the IAM decision. #398 adds a v1.1.0 entry at the top of Behavior Changes by Release in docs/manuals/07-upgrade-manual.md.
…ntries

Behavior Changes by Release lists the newest release first. The entry of this branch on the dynamodb:Select, dynamodb:ReturnValues and dynamodb:ReturnConsumedCapacity defaults sat after the v0.1.15 entries, at the end of the section. It now follows the v1.1.0 entry of #398 at the top of the section. The entry keeps its text.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

Thanks, both points hold. The Testing done section now gives the commands as CI runs them, on stable and on 1.91.1, the rust-version of Cargo.toml, with the counts at 551d76c. The server crate runs 535 unit tests and no doc tests at this head. The auth crate runs 533 unit tests, 14 integration tests and 3 doc tests. The two memlock tests of the auth crate passed on the host that ran them. The 1.88.0 line is gone, and the merge of main is in 894b97d and 02ea81f.

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked at 551d76c against the list from fe9923a. Both prior findings are verified fixed; the new Optional coverage suggestion is not being posted.

Previous items: 1 fixed; 2 fixed.

@demohan demohan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 551d76c a request that leaves a member out gets the documented default for dynamodb:Select, dynamodb:ReturnValues and dynamodb:ReturnConsumedCapacity, and every row the PR measured reproduces: this head gives the service's column and main gives "ExtendDB before". Across about 130 request shapes and 16 policies on SQLite and PostgreSQL, a null or unknown Select, projection or IndexName, a lowercase projectionExpression, or a Select member on GetItem or BatchGetItem now falls to ALL_ATTRIBUTES and is denied where main returned the whole item; the Developer Guide's Example 3 allowlist now refuses reads with no projection; a broad Allow gated on Select SPECIFIC_ATTRIBUTES no longer grants a PutItem or DescribeTable carrying that member; and Null, ForAllValues, ForAnyValue, IfExists and the negated forms move as the upgrade manual says. The authorization check and the engine read the same parsed body, PartiQL is unchanged, and the cache holds policies, not decisions. The wire file passes 31 of 31 on both backends and fails the 19 rows the PR names on main, fmt, both clippy commands and the 1.91.1 check are clean, and 535 server tests pass.

Two things stand in the way. A write whose condition fails returns the stored item past a ReturnValues NONE allowlist, which main refused, on a reading of the service that was not measured. And the change that stops a request's own Select or ReturnValues member from setting the key has no test that would catch it being undone.

I will approve once a failed write with ReturnValuesOnConditionCheckFailure ALL_OLD no longer passes a ReturnValues NONE allowlist, unless the service is measured to treat it as NONE, and the member rule has wire tests.

return_values: None,
return_consumed_capacity: Some(consumed_capacity(input)),
},
"PutItem" | "UpdateItem" | "DeleteItem" => ParameterKeys {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dynamodb:ReturnValues is NONE on a write with no ReturnValues even when it sets ReturnValuesOnConditionCheckFailure: ALL_OLD. Under an Allow of PutItem, UpdateItem and DeleteItem gated on StringEquals dynamodb:ReturnValues NONE, a PutItem, DeleteItem or TransactWriteItems Put whose condition fails, with that flag set, is allowed here and the error carries the whole stored item, ssn included; main refuses it with AccessDeniedException. The Developer Guide's write-only variant of Example 3 returns ssn here the same way. The upgrade manual (07-upgrade-manual.md:411) and the security model (10-security-model.md:248) say DynamoDB ignores ReturnValuesOnConditionCheckFailure for this key, but no row measures it. Until it is measured, keeping such a write from matching NONE holds what main held. The same line is at :133.

.get("ReturnConsumedCapacity")
.and_then(|v| v.as_str())
.map(ToOwned::to_owned),
select: parameters.select,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test holds this. With the old wiring put back, so that a request's own Select or ReturnValues member sets the key, the 16 unit tests, 535 server tests and 31 wire tests all pass, and that build lets a GetItem carrying "Select":"SPECIFIC_ATTRIBUTES" with no projection pass a Deny on ALL_ATTRIBUTES and return pk, name and ssn, lets an Allow gated on Select COUNT grant a PutItem and a DescribeTable carrying that member, and lets an Allow gated on ReturnValues ALL_OLD grant a GetItem carrying it. The wire file cannot send these members because boto3 drops them; a botocore before-sign hook that adds them would let it.


/// The request's own value of `parameter`, when it is a string; `None` for a
/// missing member or a `null`. The engine reads a `null` `Select` or projection
/// member as absent, and refuses a `null` `ReturnValues` or

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional. A null ReturnValues or ReturnConsumedCapacity does reach authorization: under a Deny on ReturnValues NONE, a PutItem with "ReturnValues": null or 7 answers AccessDeniedException here and SerializationException on main, and under the NONE allowlist the reverse. Each is refused on both, so only the error class moves, but this comment and the body say it never reaches authorization.


No catalog migration or configuration change is required.

### v1.1.0: `dynamodb:Select`, `dynamodb:ReturnValues` and `dynamodb:ReturnConsumedCapacity` hold a value when the request omits the parameter

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional. The body lists "a member on an operation that does not take the parameter no longer matches" as a breaking change, and it is one on main against this head, but this section leaves it out. context.rs:179-184 still describes the three RequestParams fields as the request's parameter rather than the default.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security

Projects

None yet

3 participants