Repository navigation
fix(server): answer the account of a BackupArn before its shape - #1358
LeeroyHannigan wants to merge 9 commits into
Conversation
DescribeBackup and DeleteBackup answered a BackupArn of another account that is not a backup ARN, such as arn:aws:dynamodb:us-east-1:000000000000:x or arn:aws:s3:::bucket, with ValidationException "Invalid Backup ARN". The answer came from the shape check before authorization, which the account check of the engine never reached. The three operations gave the same answer, from the name gate, to a backup ARN of another account whose table segment is outside the pattern. RestoreTableFromBackup answered a BackupArn of another account with an empty resource, arn:aws:dynamodb:us-east-1:000000000000:, with AccessDeniedException. DynamoDB answers the account of a BackupArn before anything else about it. An ARN of six fields with a non-empty resource whose account field is not the caller's, an empty account included, gets AccessDeniedException "Access is denied". Its partition, service, region, resource and table segment do not change that answer. An ARN of fewer fields, or with an empty resource, gets ValidationException "Invalid Backup ARN". So does the caller's own backup ARN with a table segment outside the pattern. Measured in us-east-1 on 22 Nov 2026 with DescribeBackup, DeleteBackup and RestoreTableFromBackup. The account comparison of the engine moves into check_backup_arn_account and now requires a non-empty resource. The engine runs it before it resolves a BackupArn, as before. For the three operations, the name gate of the server leaves a BackupArn that the cross-account refusal reads whole to that refusal. The refusal answers it by whether the account exists. The gate runs the table segment check on the others. For DescribeBackup and DeleteBackup the gate runs the account check before authorization, ahead of the table segment check. RestoreTableFromBackup keeps its account check in the engine, after authorization, and in the gate for a target name the gate refuses, as before. The refusal checks the table segment of a BackupArn in an account the catalog holds, as the gate did for every account. Fixes #1354.
The new head of fix/1271-restore-check-order holds main and the new
head of fix/1272-invalid-backup-arn.
Conflicts:
- backup.rs: backup_arn_member. This branch moved the account check to
check_backup_arn_account. fix/1272-invalid-backup-arn reads the
fields of the ARN once, for the account check and for the partition
of an upper-case backup id. The merge keeps the move and the fields,
which the partition check reads.
- lib.rs: the pub use backup::{...} list. The merge keeps the new list
of fix/1271-restore-check-order and adds check_backup_arn_account to
it.
- table_name_gate.rs: this branch adds a test for a BackupArn of
another account. The test comes before the test for a member of
another JSON type, whose doc fix/1263-backup-arn-type changed. The
merge keeps both.
For an account that the catalog holds, the cross-account refusal checked the table segment of a BackupArn. It answered a segment outside the pattern with ValidationException "Invalid Backup ARN" on DescribeBackup, DeleteBackup and RestoreTableFromBackup. DynamoDB answers such an ARN with the owner-only ValidationException for an account that exists. Measured in us-east-1 on 25 Nov 2026 with DescribeBackup and RestoreTableFromBackup, each request twice. The refusal no longer checks the segment, so the ARN gets the owner-only text, as a backup ARN with a valid segment does. The module doc gives both measured answers. The unit test of the shape checks now expects the owner-only text for the segment in an account that the catalog holds. With the segment check put back, the test fails at that row.
Each row of the account table goes to DescribeBackup, DeleteBackup and RestoreTableFromBackup. The comment above it now names the cells measured on DynamoDB on 25 Nov 2026: - RestoreTableFromBackup for the us-west-2, aws-cn and 300-character rows, arn:aws and the caller's a b segment. - DeleteBackup for the us-west-2 row, the caller's a b segment and the empty resource. Each answer matched its row. The comment also states that the other account of the denied rows does not exist. DynamoDB answers an account that exists with the owner-only ValidationException.
The README table of the checks that the WebAssembly build does not make, docs/differences-from-dynamodb.md and docs/dynamodb-limits.md gave the answers from before this branch. They said that the server answers Invalid Backup ARN to a backup ARN of another account with a table segment outside the pattern. They also said that DescribeBackup and DeleteBackup give that text to an ARN of another account that is not a backup or table ARN. They now give the answers of this branch. A backup ARN of another account gets the answer for another account, whatever its table segment. Other ARNs of six fields with a non-empty resource and another account get "Access is denied". That answer covers an account that the catalog holds too. DynamoDB answers such an ARN with the owner-only ValidationException for an account that exists, measured on 25 Nov 2026. The two docs files name that difference. The docs of check_backup_arn_account and of the name gate now say that their measurement of 22 Nov 2026 used an account that does not exist. They also say that the check reads no catalog.
The account sentences that the last commit added to the BackupArn rows of docs/differences-from-dynamodb.md and docs/dynamodb-limits.md had up to 48 words. They now have 25 words or fewer each, with the same facts.
navareamol
left a comment
There was a problem hiding this comment.
This branch is not on top of the current head of its base. #1353 and this PR contain only the first commit of #1327 (8da64f4). #1327 is now at 2fda6a9, 58 commits further. A merge of this head with it conflicts in crates/engine/src/backup.rs, crates/engine/src/backup_requests/pitr.rs, crates/engine/src/lib.rs and crates/server/src/table_name_gate.rs, and #1353 conflicts with #1327 in the same four files. Against main the merge conflicts in backup.rs and lib.rs, so "git merge-tree shows no conflict with main" no longer holds (main changed under the old branch). The CI run is from 22 Nov on that older stack, and main now has workflows that never ran on this code. I think #1353 has to be rebased first and this PR on top of it, with CI rerun and the 17 wire rows rerun on that tree.
Your table measures 000000000000 only. I sent the same shapes to a second account that the catalog holds. ...:<other>:x gets "Access is denied", a table shaped ARN of any partition, service or region gets the owner only text, a table segment a b gets "Invalid Backup ARN" (the derived row you flag), and an empty region on DescribeBackup and DeleteBackup gets "Invalid Backup ARN" while a restore gets the owner only text. So "The partition, the service, the region, the resource and the table segment do not change the answer" holds for an account that does not exist, and I do not think it holds for one that does. Was DynamoDB sent an x ARN, or a segment outside the pattern, in an account that exists? If not, I would narrow that sentence to the account you measured.
docs/differences-from-dynamodb.md line 125 says DescribeBackup and DeleteBackup answer "Invalid Backup ARN" before any policy for a BackupArn that does not parse as a backup ARN. On this head an S3 ARN, or arn:aws:dynamodb:us-east-1:<other>:x, gets "Access is denied". I think the row needs the account rule.
Control check: if I change fields(trimmed) to fields(backup_arn) in check_backup_arn_account, every unit and gate test still passes. No row sends another account's six field ARN with leading whitespace, or a resource of only whitespace such as arn:aws:dynamodb:us-east-1:000000000000:\n. This head answers both correctly (I ran 400000 mutated ARNs against the rule in the description). A row for each in the gate table would pin the trim.
A caller with no IAM policy who restores arn:aws:s3:::bucket, x or arn:aws:dynamodb:us-east-1:<other>:x gets the IAM denial, where DescribeBackup and DeleteBackup get "Access is denied". You say that order is not measured. The first paragraph of the description reads as if all three operations answer the account first, so I would say there that a restore does it after the IAM decision for ARNs that are not table/ resources.
I checked that a caller of another account cannot tell a real backup from a missing one on any of the three operations (528 pairs over 22 spellings), and that unsigned or wrongly signed requests get the authentication error first. I found nothing to change there.
I will approve once the branch is rebased on the rebased #1353 with CI green, the account sentence is limited to what was measured, and the docs row and the trim rows are added.
The new head of fix/1271-restore-check-order holds the new head of fix/1272-invalid-backup-arn and main of 2 Dec. On main, #1521 moved the WebAssembly section of README.md to docs/webassembly.md. Conflicts: - README.md: the WebAssembly section. This branch changed two BackupArn kind rows of its table of checks, and the paragraph above the table. The merge takes the README of fix/1271-restore-check-order. It makes the same changes in docs/webassembly.md. - backup/tests.rs: the table of malformed ARNs. This branch added the account rows, and fix/1272-invalid-backup-arn added an id in mixed case after the upper-case id. The merge keeps both.
check_backup_arn_account trimmed the BackupArn before it read its account. DynamoDB reads the account from the value as sent. On 3 Dec 2026 it answered these on DescribeBackup, DeleteBackup and RestoreTableFromBackup, each request sent twice: - " arn:aws:dynamodb:us-east-1:000000000000:x", with a leading space, gets "Invalid Backup ARN". This branch answered "Access is denied". - "arn:aws:dynamodb:us-east-1:000000000000:" and a newline gets "Access is denied". This branch trimmed the newline, saw an empty resource and answered "Invalid Backup ARN". The check now reads the member untrimmed. The shape check and the lookup still trim it. The gate table, the engine table of malformed ARNs and _BACKUP_ARN_ACCOUNT_ROWS get a row for each. The docs rows of BackupArn say that the account check reads the value as sent. Authorization still reads a BackupArn trimmed. So another account's backup ARN with a leading space or tab gets "Access is denied", where DynamoDB answers "Invalid Backup ARN". Main answers it the same way.
The BackupArn row named an issue number that does not exist yet for a backup ARN of another account with a leading space or tab. The row now gives the service's answer for it instead, "Invalid Backup ARN".
|
Changes since the last review
The branch is at
7de94a14a4. These commits sit onf85a4b050, the head that the review of 2 Dec 2026 read:dca0b9cf0merges fix(engine): check a restore's override values in DynamoDB's order #1353 atcfab9313c, which holdsmainand fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327's head of 25 Nov. The conflicts:backup_arn_memberincrates/engine/src/backup.rs: this PR moved the account check tocheck_backup_arn_account. fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327 reads the fields of the ARN once, for the account check and for the partition of an upper-case backup id. The merge keeps the move and the fields, which the partition check reads.pub use backup::{...}list ofcrates/engine/src/lib.rs: fix(engine): check a restore's override values in DynamoDB's order #1353's new list withcheck_backup_arn_accountadded.15c6e0994: the cross-account refusal no longer checks the table segment of aBackupArn. In an account that the catalog holds, a backup ARN with a table segment outside the pattern now getsValidationExceptionwith the owner-only text. DynamoDB gives that answer for an account that exists (measured on 25 November and 3 December 2026). Before, it gotInvalid Backup ARN.ad2276afa: the comment above the wire table of the account rows names the cells measured on 25 November 2026. It also says that the denied rows name an account that does not exist.31f083682and3668aaa3d: the table of the checks that the WebAssembly build does not make,docs/differences-from-dynamodb.mdanddocs/dynamodb-limits.mdstate the account answers of this PR. The refusal of DescribeBackup and DeleteBackup before any policy is for aBackupArnof the caller's account. The docs ofcheck_backup_arn_accountand of the name gate say that the measurement of 22 November 2026 used an account that does not exist. They also say that the check reads no catalog.26bec30a68merges fix(engine): check a restore's override values in DynamoDB's order #1353 at9a7483aa04, which holds fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327's pushed head andmainof 2 Dec. One conflict was the WebAssembly section ofREADME.md, which docs(readme): lead with a first request, move WebAssembly to its own page #1521 moved todocs/webassembly.mdonmain. The merge makes this PR's row changes there. The other was the table of malformed ARNs incrates/engine/src/backup/tests.rs, where the merge keeps the account rows of this PR and the mixed-case id of fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327.6c53ce3774:check_backup_arn_accountreads the account from theBackupArnas sent, as DynamoDB does (measured on 3 December 2026). Before, it read the trimmed value. The gate table, the engine table of malformed ARNs and_BACKUP_ARN_ACCOUNT_ROWSget two rows each: a leading space, and a resource of only a newline. TheBackupArnrows of the two docs files say that the account check reads the value as sent.7de94a14a4: theBackupArnrow ofdocs/differences-from-dynamodb.mdgives the service's answer for another account's backup ARN with a leading space or tab.Access is deniedsentence to an account that does not exist, and says when a restore checks the account. It gives the conflicts and the test runs at the new head.What
DescribeBackup, DeleteBackup and RestoreTableFromBackup now answer the account of a
BackupArnbefore any other check of it, as DynamoDB does. A restore of an ARN that is not atable/resource checks the account after the IAM decision. The cross-account refusal does not read such an ARN.AccessDeniedExceptionwithAccess is denied. An empty account field counts as another account. DynamoDB gives that answer for an account that does not exist (measured on 22 November 2026). There, the partition, the service, the region, the resource and the table segment do not change it.ValidationExceptionwithThis action is only supported by accounts that match the resource owner’s account., whatever its table segment.ValidationExceptionwithInvalid Backup ARN. So does the caller's own backup ARN with a table segment outside the pattern.Invalid Backup ARN, and a resource that is only a newline is not empty.Before this change:
Invalid Backup ARNto an ARN of another account that is not a backup ARN, such asarn:aws:dynamodb:us-east-1:000000000000:xor an S3 bucket ARN.authz_resource::validate_operation_arnsgave that answer before authorization.Invalid Backup ARNto a backup ARN of another account whose table segment is outside the pattern. The name gate gave that answer.Access is deniedto an ARN of another account with an empty resource,arn:aws:dynamodb:us-east-1:000000000000:.The changes:
check_backup_arn_accountincrates/engine/src/backup.rsholds the account comparison ofbackup_arn_member, and it requires a non-empty resource. The engine runs it before it resolves aBackupArn.crates/server/src/table_name_gate.rs), aBackupArnthat the cross-account refusal reads goes whole to that refusal, for the three operations. For the other ARNs, DescribeBackup and DeleteBackup run the account check and then the table segment check, before authorization. RestoreTableFromBackup runs only the table segment check there. Its account check stays in the engine, after authorization, as on fix(engine): check a restore's override values in DynamoDB's order #1353.crates/server/src/authz_resource/cross_account.rs) checks no table segment. Its module doc gives the measured answers to a backup ARN with a table segment outside the pattern, and its unit test checks them.docs/webassembly.mdof the checks that the WebAssembly build does not make,docs/differences-from-dynamodb.mdanddocs/dynamodb-limits.mdgive these answers.The base of this PR is #1353.
Why
These are DynamoDB's answers, measured in us-east-1 on 22 November 2026 with signed requests. Each request went out twice and got the same answer both times. No backup exists.
<caller>is the account of the credentials, and000000000000is another account.<name>is a table name in the pattern, and<id>is01700000000000-abcdef12. AD isAccessDeniedException,Access is denied. IBA isValidationException,Invalid Backup ARN.BackupArnarn:aws:dynamodb:us-east-1:000000000000:xarn:aws:s3:::<bucket>arn:aws:dynamodb:us-east-1::xarn:aws:iam::000000000000:role/xarn:aws:dynamodb:us-west-2:000000000000:xarn:aws-cn:dynamodb:cn-north-1:000000000000:xarn:aws:dynamodb:us-east-1:000000000000:table/a b/backup/<id>arn:aws:dynamodb:us-east-1:000000000000:arn:aws:dynamodb:us-east-1:000000000000:table/<name>arn:aws:dynamodb:us-east-1:000000000000:table/<name>/backup/<id>tarn:aws:dynamodb:us-east-1::xarn:aws:dynamodb:us-east-1:<caller>:table/a b/backup/<id>arn:aws:dynamodb:us-east-1:<caller>:xarn:aws:dynamodb:us-east-1:<caller>:table/<name>arn:aws:dynamodb:us-east-1:000000000000arn:aws:dynamodb:us-east-1:000000000000:xandarn:awsWith this PR, the 27 requests get DynamoDB's type name and message, where 13 did on #1353. The 33 earlier rows of #1272 and #1271 that name a
BackupArnof another account get the same answers as on #1353. One of them differs from DynamoDB on both trees: a ListBackupsExclusiveStartBackupArnwith an empty account field getsInvalid Backup ARN, where DynamoDB answersInvalid Request: The supplied ExclusiveStartBackupArn is not a valid backup arn. #1373 gives that cursor the service's text.On 25 November 2026 the same kind of requests went out with an account that exists, in the same way.
<account>is that account, and OWNER isValidationExceptionwith the owner-only text. In ExtendDB,<account>is an account that the catalog holds. The #1353 column of these rows comes from its code. On 3 December 2026 DescribeBackup got OWNER again for thexrow and for the table segmenta b.BackupArnarn:aws:dynamodb:us-east-1:<account>:table/<name>/backup/<id>arn:aws:dynamodb:us-east-1:<account>:table/a b/backup/<id>arn:aws:dynamodb:us-east-1:<account>:xarn:aws:dynamodb:us-east-1:<account>:xOn 3 December 2026 these went out with whitespace, in the same way, with
<id>as01791976431438-73d8d5bc:BackupArnarn:aws:dynamodb:us-east-1:000000000000:xarn:aws:dynamodb:us-east-1:000000000000:and a newlinearn:aws:dynamodb:us-east-1:000000000000:table/t367name/backup/<id>A restore can come from a caller that the IAM decision denies, with a
BackupArnof another account that the cross-account refusal does not read. Such a restore gets the IAM denial, as on #1353. DynamoDB's order of these two answers is not measured.Fixes #1354
Testing done
At
7de94a14a4, each cargo command with--locked:cargo +1.97.0 test -p extenddb-core -p extenddb-engine -p extenddb-server --lib --no-fail-fast: core 1260 passed and 1 ignored, engine 982 passed, server 524 passed. On this host 5backup_store::testsof the server fail on every branch,mainincluded, because another user owns/local/home.cargo +1.97.0 clippyof the core, engine, server and storage crates with--all-targets -- -D warnings, the same command with--features extenddb-engine/backup-test-hooks,cargo +1.94.0 checkof the four crates with--all-targets, andcargo +1.97.0 fmt --all -- --checkare clean.cargo +1.97.0 test -p extenddb-wasm-adapter: the 3 unit tests pass, and the parity test passes all 281 cases of the corpus. The clippy step of the WebAssembly workflow is clean.tests/test_backup_restore_fidelity.py56 passed, with the 17 rows oftest_backup_arn_account_is_checked_before_its_shape, andtests/test_authz_cross_account.py19 passed.pytest --collect-only -qcollectstests/andtests/pythonwith no error. The three operations got the answers of the tables above for the resourcesx,table/a b/backup/<id>andtable/<name>/backup/<id>. They did so in an account that the catalog holds and in one that it does not hold.6c53ce3774: with the trimmed read put back incheck_backup_arn_account, the engine test of malformed ARNs and the gate testa_backup_arn_of_another_account_is_refused_before_its_shapefail at the new rows.dca0b9cf0, the cross-account test with its new expectation ran with the segment check still in place. It failed at the backup ARN with the table segmenta bin an account that the catalog holds. It gotInvalid Backup ARN, where it expects the owner-only text.f85a4b050, against ExtendDB on SQLite (a release build), the 27 requests and the 33 earlier rows got the answers above. With a caller that the IAM decision denies, the restore ofarn:aws:s3:::<bucket>with a valid target got the IAM denial.Line counts at
7de94a14a4, against #1353's head9a7483aa04: production +65 -20, tests +253 -1, docs +6 -6. The test files, the parity corpus and the lines after#[cfg(test)]andmod testscount as tests, and.mdfiles as docs.git merge-treeshows no conflict withmainatc8e66fb568. This PR adds no conflict with any of the 106 open PRs that change the files of this stack.Not in this PR:
table/...resource, such asarn:aws:dynamodb:us-east-1:<account>:x, getsAccess is denied. DynamoDB answers the owner-only ValidationException for an account that exists (measured on 25 November and 3 December 2026, A BackupArn of an account the catalog holds that is not a table resource gets Access is denied, where DynamoDB answers the owner-only text #1555).BackupArnthroughtrim_backup_arn, as onmain. So another account's backup ARN with a leading tab getsAccess is denied, where DynamoDB answersInvalid Backup ARN. fix(backup): strip only one trailing line terminator from a backup ARN #1328, which fixes BackupArn with leading or trailing whitespace resolves; DynamoDB accepts only one trailing line terminator #617, changes that function to strip one trailing line terminator only.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
Breaking changes
DescribeBackup and DeleteBackup answer an ARN of another account whose resource is not a
table/...resource, such asarn:aws:dynamodb:us-east-1:000000000000:x, withAccessDeniedExceptionAccess is denied. Before, they answeredInvalid Backup ARN. On the three operations, a backup ARN of another account with a table segment outside the pattern gets the answer for another account. Before, it gotInvalid Backup ARN. A restore of an ARN of another account with an empty resource getsInvalid Backup ARN, where it gotAccess is denied. The account check reads the value as sent, so an ARN of another account whose resource is only a newline getsAccess is denied. A client that matches on the old texts sees the new ones. ABackupArnof the caller's account gets the same answer as before.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.