Repository navigation
fix(server): default dynamodb:Select, ReturnValues and ReturnConsumedCapacity condition keys - #738
LeeroyHannigan wants to merge 25 commits into
Conversation
…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.
|
|
||
| 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 |
There was a problem hiding this comment.
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.
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.
|
Thanks, both points hold. The Testing done section now gives the commands as CI runs them, on stable and on 1.91.1, the |
LJMart11
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Changes since the last review
origin/main(at 80490c6) into the branch. No file conflicted. Of the files this PR changes, main changedcrates/server/src/request_helpers.rs(fix(query): check Query values against the key schema and the number rules #544 adds a Query request check before the IAM decision) anddocs/manuals/07-upgrade-manual.md(docs(upgrade): correct four sentences of the 1.0.0 upgrade notes #1133, fix(engine): compare the Return fields on a TransactWriteItems token replay #526 and fix(metrics): bound latency segment memory by summing into fixed time buckets #398).rust-versionofCargo.toml.What
dynamodb:Select,dynamodb:ReturnValuesanddynamodb:ReturnConsumedCapacitynow 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 ownSelect,ReturnValuesandReturnConsumedCapacityalone, 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.dynamodb:SelectGetItem,QueryandScan, each table of aBatchGetItem, eachGetof aTransactGetItemsSPECIFIC_ATTRIBUTESwith aProjectionExpressionorAttributesToGet,ALL_ATTRIBUTESwithout onedynamodb:SelectQueryorScanwithIndexNameand no projectionALL_PROJECTED_ATTRIBUTESdynamodb:ReturnValuesPutItem,UpdateItemandDeleteItem, and thePut,UpdateandDeleteitems of aTransactWriteItemsNONEdynamodb:ReturnConsumedCapacityGetItem,PutItem,UpdateItem,DeleteItem,QueryandScan, and each table or item of aBatchGetItem,BatchWriteItem,TransactGetItemsorTransactWriteItemsNONEA
QueryorScanthat carriesSelectholds it as given. ABatchWriteItemand aConditionCheckleavedynamodb:ReturnValuesabsent, as before.Changes:
crates/server/src/parameter_keys.rsbuilds the three values for a single-table request, for one table of a batch and for one transaction item. Both authorization branches inrequest_helpers.rstake the values from it.AuthzTargetincrates/server/src/leading_keys/batch.rscarries the values. Transaction items that give the same target are still evaluated once. On a table with a sort key, take aGetthat projectspkand aGetof another item in the same partition that projects nothing. Both hold the samedynamodb:LeadingKeysanddynamodb:Attributes. They now give two targets, so the secondGetis evaluated withALL_ATTRIBUTES.GetItem,BatchGetItemandTransactGetItemstake noSelectparameter, so theirdynamodb:Selectcomes from the projection alone. Before this change aSelectmember in aGetItemwas copied into the key. The engine ignores that member, so with the member copied, aGetItemwith"Select": "SPECIFIC_ATTRIBUTES"and no projection would pass aDenyonALL_ATTRIBUTESand return the whole item.Selecton aPutItem,DeleteItemorDeleteTable, or aReturnValueson aGetItem,QueryorScan. AnAllowof 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.nullProjectionExpression,AttributesToGetorSelectreads as absent, as the engine does, so the key falls to the default. The engine refuses anullReturnValuesorReturnConsumedCapacitywith aSerializationException, so such a request never reaches authorization.The branch started from the head of #732, which merged on 2026-11-11, and has
origin/mainmerged in.Why
With the key absent, IAM's rules for a missing key decided these statements differently from DynamoDB:
DenyGetItemwithStringNotEqualsIfExists {"dynamodb:Select": "SPECIFIC_ATTRIBUTES"}GetItemwith a projectionDenyGetItem,QueryandScanwithStringEquals {"dynamodb:Select": "ALL_ATTRIBUTES"}AllowPutItemonly withStringEquals {"dynamodb:ReturnValues": "NONE"}PutItemwithoutReturnValuesThe second row let a whole-item read through a
Denythat DynamoDB enforces. The same gap has an Allow side. The Developer Guide's Example 3 is an allowlist that grants reads gated onStringEqualsIfExists {"dynamodb:Select": "SPECIFIC_ATTRIBUTES"}. It granted a read with no projection, because the absent key satisfied theIfExists. That read returns the whole item, attributes outside the allowlist included. After this change the key holdsALL_ATTRIBUTESon 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): Allowdynamodb:*on the table, and Deny the actionsAwithStringNotEqualsIfExists {"dynamodb:Select": "SPECIFIC_ATTRIBUTES"}.deny-all(A): Allowdynamodb:*on the table, and Deny the actionsAwithStringEquals {"dynamodb:Select": "ALL_ATTRIBUTES"}.allow-only A RV=NONE: the only statement allowsAwithStringEquals {"dynamodb:ReturnValues": "NONE"}.RCC=NONEis the same overdynamodb:ReturnConsumedCapacity, andSelect=SPECIFICoverdynamodb:SelectwithSPECIFIC_ATTRIBUTES.The "ExtendDB before" column is the answer of a build of #732's head.
GetItem ProjectionExpression #nGetItem, no projectionQuery ProjectionExpression #nQuery, no projectionGetItem, no projectionGetItem ProjectionExpression #nQuery, no projectionScan, no projectionScan Select COUNTQuery Select COUNTBatchGetItem, no projectionBatchGetItem ProjectionExpression #nBatchGetItem ProjectionExpression #nTransactGetItemsGet, no projectionTransactGetItemsGetProjectionExpression #nPutItemwithoutReturnValuesPutItem ReturnValues ALL_OLDUpdateItemwithoutReturnValuesUpdateItem ReturnValues ALL_NEWDeleteItemwithoutReturnValuesDeleteItem ReturnValues ALL_OLDBatchWriteItemwith one PutRequestTransactWriteItemswith one UpdateTransactWriteItemswith one PutTransactWriteItemswith one DeleteGetItemwithoutReturnConsumedCapacityGetItem ReturnConsumedCapacity TOTALBatchWriteItemwith one PutRequest, noReturnConsumedCapacityTransactGetItemswith one Get, noReturnConsumedCapacityThese were not measured, and the code, tests and docs say so:
ALL_PROJECTED_ATTRIBUTESon aQueryorScanof an index with no projection and noSelect. The DynamoDB API reference forQuerygives it as the default when neitherSelectnorProjectionExpressionis given on a read of an index.dynamodb:ReturnConsumedCapacityonPutItem,UpdateItem,DeleteItem,Query,Scan,BatchGetItemand the items of aTransactWriteItems, which follows the measured rows.AttributesToGetas a projection fordynamodb:Select, which follows theProjectionExpressionrows. The engine readsAttributesToGetas a projection.Gets of one partition in aTransactGetItemsthat differ only in their projection, which follows theTransactGetItemsrows.Testing done
tests/test_dynamodb_condition_key_defaults.pyis 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 threetests/test_dynamodb_attributes_*.pyfiles (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.tests/test_dev_mode_authorization.py, which needs a dev-mode build. Each test ran with its own test credentials, asdevtools/run-testsprovisions them.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.crates/server/src/parameter_keys/tests.rscover each default, a given value winning over it,nullmembers, and theSelectmember of aGetItemand of aBatchGetItemtable. They also cover keys an operation does not take, operations that get no default, and the batch and transaction targets.GetItemdefault, 3 unit tests fail, and on SQLite the twoGetItemwire tests of the first table fail (2 of 31).ALL_ATTRIBUTESin place ofALL_PROJECTED_ATTRIBUTESfor an index read, 1 unit test and the index wire test fail (1 of 31).Getwire test fail (1 of 31).ReturnValueson transaction items, 2 unit tests and the three transaction write wire tests fail (3 of 31).nullprojection counted as a projection, 1 unit test fails.ReturnConsumedCapacitydefault on single-table requests, 1 unit test fails.Selectmember read onPutItem,UpdateItemandDeleteItem, 1 unit test fails. The same holds with aReturnValuesmember read onGetItem,QueryandScan, and with the three members read on a control-plane request.cargo fmt --all -- --checkpasses, andcargo clippy --locked -p extenddb-server -p extenddb-auth --all-targets -- -D warningsgives no warning.cargo check --locked -p extenddb-server -p extenddb-auth --all-targetspasses on 1.91.1, therust-versionofCargo.toml. The test CI job runs on stable and on 1.91.1.cargo test --locked -p extenddb-server -p extenddb-authon 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 arebackup_storetests. 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/homeis 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
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, 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:ReturnValuesordynamodb:ReturnConsumedCapacitycan decide differently after this change (recorded in the upgrade manual under v1.1.0):A
Denygated onStringEqualswithdynamodb:SelectALL_ATTRIBUTESnow refuses aGetItem,QueryorScanwith no projection and noSelect, aBatchGetItemtable with no projection, and aTransactGetItemsGetwith no projection. It does not refuse aQueryorScanof an index with no projection, which holdsALL_PROJECTED_ATTRIBUTES.A
Denygated onStringNotEqualsorStringNotEqualsIfExistswithdynamodb:SelectSPECIFIC_ATTRIBUTESstops refusing reads that project, and still refuses reads without a projection.An
Allowgated onStringEqualswithdynamodb:SelectSPECIFIC_ATTRIBUTESnow grants a read that projects withoutSelect. It no longer grants aGetItemwith no projection that carries aSelectmember of that value.An
Allowgated onStringEqualswithdynamodb:ReturnValuesNONEnow grants aPutItem,UpdateItemorDeleteItemwithoutReturnValues, and thePut,UpdateandDeleteitems of aTransactWriteItems. It still refuses aBatchWriteItem.An
Allowgated onStringEqualswithdynamodb:ReturnConsumedCapacityNONEnow grants the item, batch and transaction requests itsActioncovers that carry noReturnConsumedCapacity.A
Denygated onStringNotEqualsorStringNotEqualsIfExistswithdynamodb:ReturnValuesNONEstops refusing aPutItem,UpdateItem,DeleteItemor transaction write item that omits it. It still refuses aBatchWriteItemand aConditionCheck. The same shape overdynamodb:ReturnConsumedCapacityNONEstops refusing theGetItem,PutItem,UpdateItem,DeleteItem,Query,Scanand the tables and items of a batch or transaction that omit it. It still refuses aSearchVectorsthat omits it.Nullwith valuetrueon one of the three keys no longer matches the requests that now hold the key. Fordynamodb:Selectthose are aGetItem,Query,Scan,BatchGetItemorTransactGetItems. Fordynamodb:ReturnValuesthey are aPutItem,UpdateItem,DeleteItemor transaction write item. Fordynamodb:ReturnConsumedCapacitythey are the item, batch and transaction requests. It still matches aBatchWriteItemand aConditionCheckfordynamodb:ReturnValuesand aSearchVectorsfordynamodb:ReturnConsumedCapacity, which leave the key absent.Nullwith valuefalsenow matches the requests that hold the key.An
Allowgated onStringEqualsIfExistswithdynamodb:SelectSPECIFIC_ATTRIBUTES, the Developer Guide's Example 3, granted everyGetItem,BatchGetItemandTransactGetItemsitsActioncovered and everyQueryorScanwithoutSelect, because the absent key satisfied theIfExists. 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
Allowgated onStringEqualswithdynamodb:SelectALL_PROJECTED_ATTRIBUTES, the Developer Guide's Example 5 second policy, now grants aQueryorScanof an index with no projection and noSelect. 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
Allowof a broad action gated ondynamodb:Selectgranted aPutItemor aDeleteTablethat carried a matchingSelectmember.An
IfExistsor 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_ATTRIBUTESorNONE) now matches the requests that hold it.Not covered
SearchVectorstakesReturnConsumedCapacityand neitherSelectnorReturnValues. Itsdynamodb:ReturnConsumedCapacityholds the parameter when the request carries it and is absent otherwise, as before. The service authorization reference lists no condition keys for theSearchVectorsaction, 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.