Skip to content

fix(server): answer a restore's override kinds and account before its name - #1284

Open
LeeroyHannigan wants to merge 7 commits into
fix/1246-restore-target-typefrom
fix/1245-restore-name-after-account
Open

LeeroyHannigan wants to merge 7 commits into
fix/1246-restore-target-typefrom
fix/1245-restore-name-after-account

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

  • a8189443ca merges fix(server): refuse a restore's TargetTableName of another JSON type first #1267's new head e4d210f6a4, which contains main at b3510a93ee. It has one conflict, in README.md: docs(readme): lead with a first request, move WebAssembly to its own page #1521 moved the WebAssembly section of the README to docs/webassembly.md. The merge keeps the README of main and makes the two README edits of this PR in docs/webassembly.md. The other lines this PR changes stay the same.
  • 8a0bd882b2: test_other_account_answer_depends_on_operation_and_account in tests/test_authz_cross_account.py also sends a RestoreTableFromBackup with the refused name a b. It sends the BackupArn of the known account and of the unknown one, and expects the owner-only ValidationException and Access is denied. DynamoDB gave these two answers on 3 December 2026, for an account that exists and for one that does not.
  • The description gives those measurements and the test runs at the new head.

What

When the server refuses the TargetTableName of a RestoreTableFromBackup, it now checks two other faults first, as DynamoDB does:

  • A top-level override member of another JSON kind gets a SerializationException.
  • A BackupArn of another account goes on to the cross-account refusal. That refusal gives the answer that a request with an accepted name gets.

Before this change, such a request got the answer for the name: the length text or the pattern clause at targetTableName.

The new function check_restore_override_kinds in crates/engine/src/backup.rs does the kind check. It copies only the top-level override members whose JSON kind is not the model's. Then it runs the engine's two override parses on those members. The texts are the ones these parses give for a name the server accepts. A member of the model's kind does not go to the parses here. Its other faults keep the answer for the name, as on DynamoDB. These faults are a missing member, a value outside an enum, a throughput below 1 or a fraction.

The gate change is in the RestoreTableFromBackup arm of check_table_name_chars in crates/server/src/table_name_gate.rs. It runs only for a refused name. The account check calls cross_account::find, which the cross-account refusal also calls. Between the gate and that refusal, authorize_request looks up no table for this operation.

The list of the six members and their kinds is a second copy. The parses hold the same names and kinds as code, in a match arm, a serde type and a helper. The filter cannot read them from there.

Two values of another kind keep the answer for the name, because the parse reads them with no error. These are a ProvisionedThroughputOverride list of two integers and a BillingModeOverride object of one key. DynamoDB answers SerializationException for both, with any name (#1106).

For a BackupArn of an account that exists in ExtendDB, every name now gets the owner-only ValidationException (This action is only supported by accounts that match the resource owner’s account.). DynamoDB gave that answer on 3 December 2026 to a BackupArn of an account that exists. The answer was the same with a name it refuses and with one it accepts.

The base of this PR is #1267.

Why

These are DynamoDB's answers, measured in us-east-1 on 20 and 21 November 2026, and on 25 November 2026 for OnDemandThroughputOverride. Each request went out twice and got the same answer both times. Each request names a backup that does not exist. OWN is a BackupArn of the caller's account, and OTHER is one of an account that DynamoDB does not hold. EXISTING is one of an account that exists and is not the caller's. In ExtendDB, EXISTING is an account that the deployment holds. Each row has OWN unless it names another BackupArn. The TargetTableName is a* unless the row gives another name. SE is SerializationException. LENGTH is TableName must be at least 3 characters long and at most 255 characters long.

Members DynamoDB ExtendDB on #1267 ExtendDB with this PR
OTHER AccessDeniedException, Access is denied LENGTH Access is denied
OTHER, name a b, or t, U+0000, x Access is denied the pattern clause at targetTableName Access is denied
EXISTING, name a* or a b (3 December 2026) ValidationException This action is only supported by accounts that match the resource owner’s account. LENGTH or the pattern clause the same as DynamoDB
EXISTING, a valid name (3 December 2026) the same the same the same
GlobalSecondaryIndexOverride {} SE LENGTH SE
GlobalSecondaryIndexOverride {}, name a b SE the pattern clause SE
LocalSecondaryIndexOverride {}, SSESpecificationOverride 5, ProvisionedThroughputOverride "x" or BillingModeOverride 5 SE LENGTH SE
OnDemandThroughputOverride 5 (measured on 25 November 2026) SE LENGTH SE
OTHER, and GlobalSecondaryIndexOverride {} or SSESpecificationOverride 5, in either order SE LENGTH SE
BackupArn x or no BackupArn, and GlobalSecondaryIndexOverride {} SE LENGTH SE
BillingModeOverride PAY, and SSESpecificationOverride 5, GlobalSecondaryIndexOverride {} or ProvisionedThroughputOverride "x" SE LENGTH SE
OTHER, and BillingModeOverride PAY or GlobalSecondaryIndexOverride [{}], in either order Access is denied LENGTH Access is denied
BillingModeOverride PAY or PROVISIONED, a ProvisionedThroughputOverride with a member absent, below 1 or of 1.5, or an index entry with a missing member or a value outside its set LENGTH LENGTH LENGTH
ProvisionedThroughputOverride [1, 1], or BillingModeOverride {"PROVISIONED": null} or {"PAY_PER_REQUEST": null} SE LENGTH LENGTH (#1106)

With this change, ExtendDB gives DynamoDB's exception type to each row but the last. In the SE rows, ExtendDB's text also names the member, and DynamoDB's texts are #1012. A name that the server accepts keeps its answer.

Fixes #1245

Testing done

At 8a0bd882b2, each cargo command with --locked:

  • cargo +1.97.0 test -p extenddb-core -p extenddb-engine -p extenddb-server -p extenddb-storage --lib: core 1259 passed and 1 ignored, engine 982 passed, server 523 passed and 5 failed, storage 294 passed. On this host 5 backup_store::tests fail on every branch, because uid 65534 owns /local/home.
  • cargo +1.97.0 fmt --all -- --check is clean. cargo +1.97.0 clippy of the four crates with --all-targets -- -D warnings is clean, and so is the same command with --features extenddb-engine/backup-test-hooks. cargo +1.94.0 check of the four crates with --all-targets is clean. cargo +1.97.0 test -p extenddb-wasm-adapter: the 3 unit tests pass, and the parity test passes over the 279 cases of the corpus. The clippy step of the WebAssembly workflow, run on this branch, is clean.
  • The unit test a_refused_restore_target_name_is_answered_after_the_types_and_the_account has 23 rows. One row sets the six override members to null, which DynamoDB answers with LENGTH. On a revision before bcd9f7f17, with the two gate statements removed, the test failed at its first row. On aa56f36e7, with the OnDemandThroughputOverride arm removed from the kind filter, it failed at the OnDemandThroughputOverride row.
  • The new table of test_backup_and_table_names_are_validated has 17 rows. Against a server built from 8022210a8, the fix(server): refuse a restore's TargetTableName of another JSON type first #1267 head that this branch started from, the table failed at its first row.
  • Against ExtendDB on SQLite built from this head, 215 wire tests passed: tests/test_backup_restore_fidelity.py 37, tests/test_continuous_backups.py 9, tests/test_authz_cross_account.py 19, tests/test_authz_resource_arn.py 49, tests/python/test_nul_table_name_fields.py 52, tests/python/test_nul_arn_shapes.py 48 and tests/python/test_warm_throughput_backup.py 1. These tests include the new row of the cross-account test and the OnDemandThroughputOverride row of the wire table. The 46 tests of tests/test_backup_job.py skipped, because they start their own server from EXTENDDB_BINARY and these runs did not set it. The head of fix(server): refuse a restore's TargetTableName of another JSON type first #1267, e4d210f6a4, does not have the gate change. Against a server built from it, the cross-account test fails at the new row. There the known account's BackupArn with a b gets the pattern clause at targetTableName. pytest --collect-only -q collects 7301 tests in tests/ and 820 in tests/python, with no error.
  • The rows of the table above went to a SQLite server built from bcd9f7f17, the first commit of this PR, and got the answers shown. That run did not have the OnDemandThroughputOverride row or the EXISTING rows.
  • On a PostgreSQL server built from bcd9f7f17, names with U+0000 or of 204,800 characters got no HTTP 500. They went beside OTHER and beside the BackupArn of an account that exists in ExtendDB. Every answer on both backends was HTTP 400.

Line counts: production +43 -3, tests +115, docs +4 -2.

This PR adds no conflict with the open PRs or with main. #1273 merges cleanly with it.

Not in 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

When the server refuses a restore's TargetTableName, it now answers two other faults before the name. An override member of another JSON kind gets SerializationException, and a BackupArn of another account gets the cross-account answer. Before this change, these requests got the length text or the pattern clause of the name, as the table in Why shows. A name that the server accepts keeps its answer.


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.

… name

RestoreTableFromBackup answered a TargetTableName outside the pattern
before two faults that DynamoDB answers first. These are an override
member of another JSON kind and a BackupArn of another account.

DynamoDB answers SerializationException for the first. For a BackupArn
of an account that does not exist, it answers AccessDeniedException with
"Access is denied". This was measured in us-east-1 on 20 Nov 2026, with
each request sent twice. The service answers the name's length before
the other override faults, such as a missing member, an unknown enum
value or a fraction.

When the server refuses the target name, it now first checks the JSON
kind of each top-level override member. A member of another kind that
the engine's override parse refuses gets the parse's
SerializationException. The parse accepts a ProvisionedThroughputOverride
list of two integers and a BillingModeOverride object of one key, so
these two keep the name's answer (#1106). A request whose BackupArn
names another account then goes on to the cross-account refusal. That
refusal gives the answer a name the server accepts gets, and nothing
before it looks a table up. A name the server accepts keeps its answer.

Fixes #1245.
…ccount

Conflict in lib.rs, in the pub use backup::{...} list. This branch
adds check_restore_override_kinds to the list. Main moved
check_restore_table_name and refuse_point_in_time_recovery from the
list to backup_requests. This merge keeps main's list and adds
check_restore_override_kinds to it.
No test sent an OnDemandThroughputOverride of another JSON kind with a
TargetTableName that the server refuses. A build without the
OnDemandThroughputOverride arm of check_restore_override_kinds passed
the engine backup tests and the gate tests. DynamoDB answers
SerializationException to an OnDemandThroughputOverride of 5 with the
target a*, measured in us-east-1 on 25 Nov 2026 with the request sent
twice. The unit table of the gate and the wire table now have that
row.
check_restore_override_kinds cloned the whole request body and then
removed each member that is not an override of another JSON kind. It
now copies only those overrides. The answers do not change.
The README lists the checks that the WebAssembly build does not make.
Its row for a restore's TargetTableName outside the pattern said that
the server checks only the BackupArn kind first. The server now checks
the JSON kind of each override member before the name. It passes a
BackupArn of another account to the accounts answer. The row gives that
order, and the restore's length text, which counts UTF-16 code units.
The paragraph on check order names the exception.

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

CI has not finished on this head. The integration, cassandra-integration and mongodb-integration jobs were cancelled before any step ran, on 25 Nov between 22:24:54 and 22:24:57, and nothing ran after that. integration is also the job that runs devtools/test-shards check, so the check that the shards ran every test once did not run. wasm fails on web_time::Instant against std::time::Instant in crates/core/src/metrics/collector.rs:60, which #1482 fixed on main after this head was pushed. I merged main 222d80a into this head locally: no conflict, the engine, server and core lib tests pass, and the six wire files from the description pass on SQLite. Could you merge main so CI runs to the end on that tree?

A question on the account branch. With a BackupArn of an account the deployment holds, a refused name now gets "This action is only supported by accounts that match the resource owner's account." I measured that for a*, for t, U+0000, x and for a 200 KB name; before this change they got the length text or the pattern clause. The measured row OTHER gets "Access is denied", which ExtendDB gives for an account it does not hold, so I think OTHER was an account that does not exist. Has DynamoDB been asked a refused name with a BackupArn of an account that exists? If it answers the name, I think the gate should pass on only an account the deployment does not hold.

I will approve once CI is green on a branch with main merged and the account question has an answer.

…ccount

The parent branch now contains main at b3510a9.

Conflict in README.md: #1521 moved the WebAssembly section of README.md
to docs/webassembly.md. This merge keeps main's README.md. It makes the
two README edits of this branch in docs/webassembly.md. The first puts
the account of the BackupArn before the table names check of the
TargetTableName. The second is the TargetTableName row of the table
names check.
DynamoDB answers the account of the BackupArn before a TargetTableName
outside the pattern. A BackupArn of an account that exists gets the
ValidationException that the cross-account test calls OWNER_ONLY. One
of an account that does not exist gets "Access is denied" (measured in
us-east-1 on 3 Dec 2026). The cross-account test now sends "a b" with
the BackupArn of the known and of the unknown account.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  • main: a818944 merges the new head of fix(server): refuse a restore's TargetTableName of another JSON type first #1267, which contains main at b3510a9. Its one conflict was README.md, where docs(readme): lead with a first request, move WebAssembly to its own page #1521 moved the WebAssembly section to docs/webassembly.md. The merge keeps the README of main and makes the two README edits of this branch in docs/webassembly.md. CI runs on that tree after the push.
  • The account question: DynamoDB answers the account first for an account that exists too. On 3 December 2026 in us-east-1, each request sent twice, a BackupArn of an account that exists and is not the caller's got ValidationException This action is only supported by accounts that match the resource owner’s account.. That was the answer with the targets a* and a b, and with a valid name. A BackupArn of OTHER, which DynamoDB does not hold, got AccessDeniedException Access is denied with a* and with a b. This head gives these two answers for an account the deployment holds and for one it does not hold. So the gate stays as it is. 8a0bd88 adds the refused name a b to the cross-account test, with the BackupArn of the known account and of the unknown one. The new head of fix(server): refuse a restore's TargetTableName of another JSON type first #1267 does not have this gate change. Against a server built from it, the new row fails: the known account gets the pattern clause at targetTableName.

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

The account question is answered. Your 3 December measurements show DynamoDB answering the account first for an account that exists as well, with the owner only text for a* and a b and for a valid name, and Access is denied for OTHER. That is what this head gives, so the gate stays as it is and my suggestion to pass on only the unknown account does not apply.

I ran the new cross account row, a b as the target name with the BackupArn of a known and of an unknown account, on a SQLite build of this branch with current main. It passes, and I checked that it detects the change: against a build of the new head of #1267 the known account gets the pattern clause at targetTableName, and with the account branch switched off the known account gets Access is denied. Unsigned, wrong secret, unknown key and tampered requests with every new branch still get the authentication errors first.

The README edits are in docs/webassembly.md now, main's README is untouched, and every check on 8a0bd88 is green. On the merged tree clippy with warnings as errors, fmt, the engine, server and core lib tests and the wasm adapter parity test pass.

I approve this PR.

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