Repository navigation
fix(engine): refuse a BackupArn table segment of a bad length - #1367
LeeroyHannigan wants to merge 5 commits into
Conversation
DynamoDB refuses a BackupArn whose table segment is outside the length bounds of a table name. It answers ValidationException "Invalid Backup ARN" on DescribeBackup, DeleteBackup and RestoreTableFromBackup. The restore gives this answer before it checks the TargetTableName. ExtendDB gave that answer only on a restore with a valid target name. DescribeBackup and DeleteBackup answered BackupNotFoundException. A restore with a target name that the server's name gate refuses got the length text for the name. Measured in us-east-1 on 22 Nov 2026, each request twice. Each BackupArn names a backup of the caller's account that does not exist. The target name is valid unless the row gives one. In the table, invalid is "Invalid Backup ARN" and not found is BackupNotFoundException. Length is "TableName must be at least 3 characters long and at most 255 characters long". operation region segment target DynamoDB before DescribeBackup us-east-1 ab invalid not found DeleteBackup us-east-1 ab invalid not found DescribeBackup us-east-1 300 t invalid not found DeleteBackup us-east-1 300 t invalid not found RestoreTableFromBackup us-east-1 ab a* invalid length RestoreTableFromBackup us-east-1 300 t a* invalid length RestoreTableFromBackup us-east-1 a b a* invalid invalid RestoreTableFromBackup us-west-2 ab invalid invalid RestoreTableFromBackup us-west-2 300 t invalid invalid RestoreTableFromBackup us-east-1 ab invalid invalid RestoreTableFromBackup us-east-1 300 t invalid invalid The length check of the restore moves into the BackupArn check that the three operations and the name gate share. It runs after the account check, with the shape checks and before the target name. DescribeBackup, DeleteBackup and the restore pass the deployment's table name bounds. The name gate passes the bounds it uses for the target name, 3 to 255. DescribeBackup and DeleteBackup refuse a bad length only when they find no backup. A stored backup outside the current bounds is still described and deleted. The restore refuses it, as before. Fixes #1361.
navareamol
left a comment
There was a problem hiding this comment.
I think a stored backup whose table name is outside the current [limits] still cannot be restored. DescribeBackup and DeleteBackup now look the backup up first and answer "Invalid Backup ARN" only when nothing is found, but restore_table_from_backup still calls backup_arn_member with the deployment's bounds before it reads the backup. I took backups of a and ab with min_table_name_length = 1, restarted with the default 3 to 255, and on this head DescribeBackup answers AVAILABLE for both while RestoreTableFromBackup of the same ARN answers "Invalid Backup ARN" (own region with a valid target, and another region with an override). The abc backup restores. On main these backups restore, so the stack would take that away. Could the restore use the same rule as DescribeBackup, refusing the length only where the not found and cross region answers are given? Changing step 2 to (0, usize::MAX) alone makes an ab ARN in another region answer the cross region text, which one of your tests catches, so the mapping is needed at both points.
The branch no longer merges with main. git merge-tree --write-tree against main at 92155f3 conflicts in crates/core/src/error/mod.rs, crates/engine/src/backup.rs, crates/engine/src/lib.rs and crates/engine/src/partiql/request_checks.rs. #1365 conflicts in the same four files, so this comes from the lower branches. The CI run is from 22 November on a tree without main's wasm, pr title and search inequality workflows. Could you rebase the stack and let CI run on the new tree?
On DescribeBackup and DeleteBackup a bad length now answers before a bad id or a bad region field: ab with id bad, or with region us/east-1 or US-EAST-1, was "Invalid Request: BackupArn is not valid" on #1365 and is "Invalid Backup ARN" here. The table in the description has no row with both faults. Has anyone checked which answer DynamoDB gives? No test pins this order: answering the inner shape fault first (let parts = parts?; in backup_arn_field) leaves every engine test green.
Smaller items:
- Nothing pins the bounds exactly. Changing
min..=maxtomin..maxinbackup_arn_member, or the gate's bounds to(3, 256), leaves all tests green. Rows for 255 and 256 characters would catch both. - The row
("us-east-1", "a b", {"TargetTableName": "a*"}, ...)passes on #1365 and on main. - The description says 872 engine tests; I count 871 on this head and on #1365. Production is +73 -29 and tests +44 -12 by the file stats, not +61 -29 and +56 -12. On a default init, CreateBackup of a 260 character table answers "table name of 260 bytes is longer than 255", so I could not repeat the 260 character stored backup case; which configuration did you use?
- The
BackupArnrows in docs/differences-from-dynamodb.md and docs/dynamodb-limits.md do not mention the length answer.
I will approve once a stored backup outside the current bounds restores again, the stack is rebased on main with CI green on that tree, the length against bad id and region order is measured or asked, and the 255 and 256 rows are added.
The new head of fix/1348-override-null-members holds the new heads of the four branches below it and main of 2 Dec. On fix/1326-cross-region-restore, the restore now looks a backup up when its table segment is outside the bounds. It refuses the segment only when no backup has that ARN. That branch adds segment_out_of_bounds for the check. Conflicts: - backup.rs: backup_arn_member and step 2 of the restore. This branch gave backup_arn_member the bounds, called it twice in backup_arn_field, and refused the segment in step 2 before any read. The merge keeps backup_arn_member without bounds and step 2 of fix/1326-cross-region-restore. backup_arn_field and check_restore_backup_arn call segment_out_of_bounds once each, with the same answers. - backup/tests.rs and test_backup_restore_fidelity.py: the doc of the cross-region test, the comment of _BACKUP_ARN_REGION_ROWS and its rows. The merge keeps the words and the rows of both sides.
No test pinned the bounds at 255 and 256 characters or the bounds of the gate. No test pinned the order of the length against a bad id or region field either. DynamoDB gave these answers on 3 Dec 2026, each request sent twice. A segment of 255 characters is BackupNotFoundException on the three operations. One of 1 or 256 characters is "Invalid Backup ARN". With the segment "ab", DescribeBackup and DeleteBackup answer the length first, whatever the id or the region field. A restore of a segment of 256 characters with the target name "a*" gets "Invalid Backup ARN" too. The new rows go into the engine table of DescribeBackup and DeleteBackup, the gate table and _BACKUP_ARN_REGION_ROWS. The docs rows now name the length answer.
The new head of fix/1348-override-null-members gives the service's answer for a padded backup ARN of another account in the BackupArn row of docs/differences-from-dynamodb.md. The row named an issue number there. Conflict: - docs/differences-from-dynamodb.md: the BackupArn row. The merge keeps the row of this branch with that one sentence changed.
The new head of fix/1348-override-null-members builds one row of the restore order test with std::slice::from_ref, which clippy asks for. The merge has no conflict.
Smaller items:
|
Changes since the last review
The branch is at
9f39cea225. These commits sit onccd0fbeaf2, the head that the review of 2 Dec 2026 read:b40fc3c239merges fix(engine): answer missing restore override members as DynamoDB does #1365 at3b921c0dd3, which holds fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327's pushed head,mainof 2 Dec and the new heads of the PRs below this one. On fix(engine): answer a restore from another region as DynamoDB does #1359, the restore now reads a backup when its table segment is outside the bounds. It refuses the segment only when no backup has that ARN. fix(engine): answer a restore from another region as DynamoDB does #1359 adds the helpersegment_out_of_boundsfor the check. The conflicts:crates/engine/src/backup.rs,backup_arn_memberand step 2 of the restore. This PR gavebackup_arn_memberthe bounds, called it twice inbackup_arn_field, and refused the segment in step 2 before any read. The merge keepsbackup_arn_memberwithout bounds and step 2 of fix(engine): answer a restore from another region as DynamoDB does #1359.backup_arn_fieldandcheck_restore_backup_arncallsegment_out_of_boundsonce each, with the same answers.crates/engine/src/backup/tests.rsandtests/test_backup_restore_fidelity.py: the doc of the cross-region test, the comment of_BACKUP_ARN_REGION_ROWSand its rows. The merge keeps the words and the rows of both sides.568ff4597eadds the rows that the review asked for, measured on 3 December 2026. A segment of 255 characters isBackupNotFoundExceptionon the three operations, and one of 1 or 256 characters isInvalid Backup ARN. On DescribeBackup and DeleteBackup, the segmentabwith the idbador the region fieldus/east-1orUS-EAST-1isInvalid Backup ARN. The rows go into the engine table of DescribeBackup and DeleteBackup, the gate table and_BACKUP_ARN_REGION_ROWS. TheBackupArnrows ofdocs/differences-from-dynamodb.mdanddocs/dynamodb-limits.mdname the length answer.a6fc681decmerges fix(engine): answer missing restore override members as DynamoDB does #1365 atab4adea834. One conflict, theBackupArnrow ofdocs/differences-from-dynamodb.md, where the merge keeps the row of this PR with the one sentence of fix(server): answer the account of a BackupArn before its shape #1358 changed.9f39cea225merges fix(engine): answer missing restore override members as DynamoDB does #1365 at13f6a213c0, with no conflict.What
DescribeBackup, DeleteBackup and RestoreTableFromBackup now answer a
BackupArnwhose table segment is outside the length bounds of a table name as DynamoDB does. When no backup has that ARN, the answer isValidationExceptionwithInvalid Backup ARN. The restore gives this answer before it checksTargetTableName, also when the server's name gate refuses the target name.backup_arn_fieldincrates/engine/src/backup.rs. A segment outside them is the answer in place of a bad id or region field. A well-formed ARN is looked up first, and the segment is refused only when neither spelling names a backup. So a stored backup whose table name is outside the current[limits]is still described and deleted.crates/server/src/table_name_gate.rspasses the bounds it uses for the target name, 3 to 255, tocheck_restore_backup_arn.The base of this PR is #1365.
Fixes #1361
Why
These are DynamoDB's answers, measured in us-east-1 with signed requests. Each request went out twice and got the same answer both times. Each
BackupArnnames a backup of the caller's account that does not exist. The target name is valid unless the row gives one.ValidationException,Invalid Backup ARN.BackupNotFoundException.Measured on 22 November 2026:
us-east-1abus-east-1abus-east-1tus-east-1tus-east-1aba*us-east-1ta*us-east-1a ba*us-west-2abus-west-2tus-east-1abus-east-1tMeasured on 3 December 2026:
ttaab, with the idbadInvalid Request: BackupArn is not validab, with the region fieldus/east-1orUS-EAST-1Invalid Request: BackupArn is not validab, with the targeta*t, with the targeta*With this PR, every request of both tables gets DynamoDB's answer.
Testing done
At
9f39cea225, 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 983 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.py124 passed andtests/test_authz_cross_account.py19 passed.pytest --collect-only -qcollectstests/andtests/pythonwith no error. The two restore rows with the targeta*of the second table got IBA.568ff4597e, each with the tests kept: withmin..maxinsegment_out_of_bounds,a_restore_of_a_backup_arn_in_another_region_is_the_cross_region_answerfails. With the gate's bounds at(3, 256),a_refused_restore_target_name_is_answered_after_the_types_and_the_accountfails. With the shape fault answered first inbackup_arn_field, the same engine test fails, where a DescribeBackup row expects IBA and getsInvalid Request: BackupArn is not valid.absegment of DescribeBackup, and the gate table failed at the restore witha*. A second control refused a bad length before the lookup. Then two tests failed on a stored backup: one of a 256-character table name and one ofabc.abcunder limits 3 to 300. The catalog kept them. It then restarted with limits 5 to 255. ListBackups listed both backups. DescribeBackup answered 200, and DeleteBackup answered 200 and deleted them. With a backup store, CreateBackup refuses a table name of more than 255 bytes. At this head the restore of such a backup reads it first:a_backup_of_a_name_outside_the_current_bounds_restoresrestores a stored backup ofab.Line counts at
9f39cea225, against #1365's head13f6a213c0: production +56 -13, tests +96 -19, docs +2 -2. 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. Of the 106 open PRs that change the files of this stack, one gets a new conflict from this PR. With #1328, this PR adds one conflict hunk incrates/engine/src/backup.rs, a file that conflicts already. The hunk is thehandle_describe_backupline: #1328 adds.map_err(|e| named_as_requested(e, ...)), and this PR adds&ctx.limits. The resolution keeps both.Not in this PR:
[limits]differ from 3 to 255, the gate and the engine can disagree on a segment. The gate used 3 to 255 for the target name before this PR.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
Invalid Backup ARNto aBackupArnwhose table segment is outside the deployment's table name bounds, when no backup has that ARN. Before, they answeredBackupNotFoundExceptionorInvalid Request: BackupArn is not valid. A restore with such a segment and a target name that the gate refuses getsInvalid Backup ARN, where it got the length text of the name. A client that matches on the old texts sees the new ones. A stored backup whose table name is outside the current bounds is described, deleted and restored 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.