Skip to content

fix(engine): refuse a BackupArn table segment of a bad length - #1367

Open
LeeroyHannigan wants to merge 5 commits into
fix/1348-override-null-membersfrom
fix/1361-segment-length
Open

LeeroyHannigan wants to merge 5 commits into
fix/1348-override-null-membersfrom
fix/1361-segment-length

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

The branch is at 9f39cea225. These commits sit on ccd0fbeaf2, the head that the review of 2 Dec 2026 read:

What

DescribeBackup, DeleteBackup and RestoreTableFromBackup now answer a BackupArn whose table segment is outside the length bounds of a table name as DynamoDB does. When no backup has that ARN, the answer is ValidationException with Invalid Backup ARN. The restore gives this answer before it checks TargetTableName, also when the server's name gate refuses the target name.

  • DescribeBackup and DeleteBackup pass the deployment's table name bounds to backup_arn_field in crates/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.
  • The restore checks the segment after the account and the shape, and before the target name, as fix(engine): answer a restore from another region as DynamoDB does #1359 does. It also looks a backup up first, so a stored backup of such a table is restored.
  • The name gate in crates/server/src/table_name_gate.rs passes the bounds it uses for the target name, 3 to 255, to check_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 BackupArn names a backup of the caller's account that does not exist. The target name is valid unless the row gives one.

  • IBA is ValidationException, Invalid Backup ARN.
  • NOTFOUND is BackupNotFoundException.
  • LENGTH is the length text of the target name.

Measured on 22 November 2026:

Operation Region field Table segment Target DynamoDB ExtendDB on #1365
DescribeBackup us-east-1 ab IBA NOTFOUND
DeleteBackup us-east-1 ab IBA NOTFOUND
DescribeBackup us-east-1 300 t IBA NOTFOUND
DeleteBackup us-east-1 300 t IBA NOTFOUND
RestoreTableFromBackup us-east-1 ab a* IBA LENGTH
RestoreTableFromBackup us-east-1 300 t a* IBA LENGTH
RestoreTableFromBackup us-east-1 a b a* IBA IBA
RestoreTableFromBackup us-west-2 ab IBA IBA
RestoreTableFromBackup us-west-2 300 t IBA IBA
RestoreTableFromBackup us-east-1 ab IBA IBA
RestoreTableFromBackup us-east-1 300 t IBA IBA

Measured on 3 December 2026:

Operation Table segment and other faults DynamoDB ExtendDB on #1365
DescribeBackup, DeleteBackup, RestoreTableFromBackup 255 t NOTFOUND NOTFOUND
DescribeBackup, DeleteBackup, RestoreTableFromBackup 256 t IBA NOTFOUND on DescribeBackup and DeleteBackup, IBA on the restore
DescribeBackup, DeleteBackup, RestoreTableFromBackup a IBA NOTFOUND on DescribeBackup and DeleteBackup, IBA on the restore
DescribeBackup, DeleteBackup ab, with the id bad IBA Invalid Request: BackupArn is not valid
DescribeBackup, DeleteBackup ab, with the region field us/east-1 or US-EAST-1 IBA Invalid Request: BackupArn is not valid
RestoreTableFromBackup ab, with the target a* IBA LENGTH
RestoreTableFromBackup 256 t, with the target a* IBA LENGTH

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 5 backup_store::tests of the server fail on every branch, main included, because another user owns /local/home.
  • cargo +1.97.0 clippy of 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 check of the four crates with --all-targets, and cargo +1.97.0 fmt --all -- --check are 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.
  • Against ExtendDB on SQLite built from this head: tests/test_backup_restore_fidelity.py 124 passed and tests/test_authz_cross_account.py 19 passed. pytest --collect-only -q collects tests/ and tests/python with no error. The two restore rows with the target a* of the second table got IBA.
  • Controls on 568ff4597e, each with the tests kept: with min..max in segment_out_of_bounds, a_restore_of_a_backup_arn_in_another_region_is_the_cross_region_answer fails. With the gate's bounds at (3, 256), a_refused_restore_target_name_is_answered_after_the_types_and_the_account fails. With the shape fault answered first in backup_arn_field, the same engine test fails, where a DescribeBackup row expects IBA and gets Invalid Request: BackupArn is not valid.
  • On 22 November 2026, a control reverted the production change and kept the tests. Then the engine table failed at the ab segment of DescribeBackup, and the gate table failed at the restore with a*. 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 of abc.
  • On 22 November 2026, a server with no backup store took backups of a table of 260 characters and of abc under 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_restores restores a stored backup of ab.

Line counts at 9f39cea225, against #1365's head 13f6a213c0: production +56 -13, tests +96 -19, docs +2 -2. The test files, the parity corpus and the lines after #[cfg(test)] and mod tests count as tests, and .md files as docs.

git merge-tree shows no conflict with main at c8e66fb568. 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 in crates/engine/src/backup.rs, a file that conflicts already. The hunk is the handle_describe_backup line: #1328 adds .map_err(|e| named_as_requested(e, ...)), and this PR adds &ctx.limits. The resolution keeps both.

Not in this PR:

  • The name gate passes 3 to 255, and the engine passes the deployment's bounds. When [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

  • 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

Breaking changes

DescribeBackup and DeleteBackup answer Invalid Backup ARN to a BackupArn whose table segment is outside the deployment's table name bounds, when no backup has that ARN. Before, they answered BackupNotFoundException or Invalid Request: BackupArn is not valid. A restore with such a segment and a target name that the gate refuses gets Invalid 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.

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 navareamol 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.

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:

  1. Nothing pins the bounds exactly. Changing min..=max to min..max in backup_arn_member, or the gate's bounds to (3, 256), leaves all tests green. Rows for 255 and 256 characters would catch both.
  2. The row ("us-east-1", "a b", {"TargetTableName": "a*"}, ...) passes on #1365 and on main.
  3. 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?
  4. The BackupArn rows 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.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  1. The merge b40fc3c239 takes the change of fix(engine): answer a restore from another region as DynamoDB does #1359 (26239c18df) for the restore. backup_arn_member takes no bounds now. When the table segment is outside the bounds, the restore reads the backup first, under the same spellings as DescribeBackup. It refuses the segment only when no backup has that ARN. An ab ARN in another region that names no backup still gets Invalid Backup ARN, as measured. DescribeBackup and DeleteBackup keep the rule of this PR, with one segment_out_of_bounds call in backup_arn_field in place of the second backup_arn_member call. The engine test a_backup_of_a_name_outside_the_current_bounds_restores restores a stored backup of ab under the default bounds at this head.
  2. The branch takes the new heads of fix(engine): answer missing restore override members as DynamoDB does #1365 with merges: b40fc3c239 (at 3b921c0dd3), a6fc681dec (at ab4adea834) and 9f39cea225 (at 13f6a213c0). git merge-tree of 9f39cea225 with main at c8e66fb568 shows no conflict. CI runs when the branch is pushed.
  3. I measured it on 3 Dec 2026, each request twice. DescribeBackup and DeleteBackup answer Invalid Backup ARN to a segment ab with the id bad, with the region us/east-1 and with the region US-EAST-1. So the length comes first, as here. 568ff4597e adds the six rows to the engine table of DescribeBackup and DeleteBackup. With the shape fault answered first in backup_arn_field, the engine test fails.

Smaller items:

  1. 568ff4597e adds the rows, measured on 3 Dec 2026. A segment of 255 characters is BackupNotFoundException on the three operations, and a segment of 1 or 256 characters is Invalid Backup ARN. The rows are in the engine table, the gate table and _BACKUP_ARN_REGION_ROWS. With min..max in the bounds check, the engine test fails. With the gate's bounds at (3, 256), the gate test fails.
  2. That row stays, because DynamoDB gave it on 22 Nov and it holds on main too. 568ff4597e adds the row with a segment of 256 characters and the target a*. DynamoDB answers Invalid Backup ARN (3 Dec 2026). fix(engine): answer missing restore override members as DynamoDB does #1365 answers the length text of the target name, TableName must be at least 3 characters long and at most 255 characters long, so this row fails there.
  3. The description now gives the test and line counts of 9f39cea225. The 260-character case ran on a server with no backup store, so the catalog kept the backups. Its [limits] were 3 to 300, and then 5 to 255. With a backup store, CreateBackup refuses a table name of more than 255 bytes, which is the answer you got.
  4. 568ff4597e adds the length answer to the BackupArn rows of docs/differences-from-dynamodb.md and docs/dynamodb-limits.md.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants