Skip to content

fix(engine): check the IndexName of a restore's index override - #1225

Open
LeeroyHannigan wants to merge 10 commits into
mainfrom
fix/1136-restore-override-index-name
Open

LeeroyHannigan wants to merge 10 commits into
mainfrom
fix/1136-restore-override-index-name

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

RestoreTableFromBackup did not check the IndexName of a GlobalSecondaryIndexOverride or LocalSecondaryIndexOverride entry. ExtendDB searched the backup for the name, so a backup that does not exist answered BackupNotFoundException. DynamoDB checks the name against the model's constraints, 3 to 255 characters of [a-zA-Z0-9_.-]. It answers the fault at the entry's member path before it reads the backup.

IndexOverrides::check_index_names in crates/engine/src/backup/overrides.rs checks each entry's name with validate_index_name, which takes a member path since #1137, at globalSecondaryIndexOverride.<n>.member.indexName or localSecondaryIndexOverride.<n>.member.indexName. restore_table_from_backup in crates/engine/src/backup.rs calls it after the BackupArn check and the TargetTableName check, and before it reads the catalog row or the backup. DynamoDB answers another account's BackupArn and a bad TargetTableName first, so the check does not run in the override parse, which comes before both.

Why

DynamoDB's answers, measured in us-east-1 on 18 and 20 November 2026. Each request went out twice and got the same answer both times. Each request named a backup that does not exist, and each override entry carried a KeySchema and a KEYS_ONLY projection.

GlobalSecondaryIndexOverride entry IndexName DynamoDB, HTTP 400 ValidationException
ab 1 validation error detected: Value 'ab' at 'globalSecondaryIndexOverride.1.member.indexName' failed to satisfy constraint: Member must have length greater than or equal to 3
😀😀 (two U+1F600) 2 validation errors detected:, the length clause and Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+
g i 1 validation error detected:, the pattern clause
256 characters 1 validation error detected:, Member must have length less than or equal to 255

A LocalSecondaryIndexOverride entry gets the same texts at localSecondaryIndexOverride.1.member.indexName. Before this change, ExtendDB answered each row with BackupNotFoundException. With this change, it answers each row as DynamoDB does.

More requests with the override name g i set the order of the checks. DynamoDB gave the last two answers on 3 December 2026, each request sent twice.

Request DynamoDB
a BackupArn of another account AccessDeniedException, Access is denied
TargetTableName ab the target name's fault, without the override name
no BackupArn Invalid Backup ARN, without the override name
BillingModeOverride BOGUS 2 validation errors detected:, the enum clause at billingModeOverride, then the pattern clause at globalSecondaryIndexOverride.1.member.indexName

ExtendDB answers the first three in DynamoDB's order. Their texts differ from DynamoDB's (#1116, #1224, and #1272 for the absent BackupArn). For the last row, ExtendDB answers the enum clause alone, because the engine checks the override values before the names (#1271).

Fixes #1136

Testing done

At 26dcbe1d73, 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 981 passed, server 521 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 engine test an_index_override_name_is_checked_before_the_backup_is_read sends 12 requests, 6 per list: the four names above, another account's BackupArn, and TargetTableName ab. The store holds no backup. The test reads each answer and checks that the restore reads neither the catalog row nor the backup. It fails with the call removed, and with the call placed before the BackupArn check or before the target name check. At 26dcbe1d73, with the call moved after the first read_catalog_row, the test fails at its first row, because the restore reads the catalog row.
  • Against ExtendDB on SQLite built from this head, tests/test_backup_restore_fidelity.py passed 37 tests and tests/python/test_warm_throughput_backup.py passed 1. In the first file, test_backup_and_table_names_are_validated holds the six rows of the issue. Against a server built from fix(core): count an index name in characters and report its member path #1137's head 8a2b168a1, it fails with BackupNotFoundException where it expects ValidationException. pytest --collect-only -q collects 7301 tests in tests/ and 820 in tests/python, with no error.

Line counts: production +24 -4, tests +90 -2.

Not in this PR:

This PR adds no conflict with an open PR or with main.

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

A RestoreTableFromBackup whose index override has an IndexName that DynamoDB refuses gets DynamoDB's ValidationException before ExtendDB reads the backup. Before this change, such a request for a backup that does not exist got BackupNotFoundException. A request with valid override names 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.

ExtendDB counted an index name in UTF-8 bytes and wrote both length
bounds in one clause. It reported each fault at the bare 'indexName',
except a pattern fault in an UpdateTable Create or Delete. DynamoDB
counts the name in characters. It writes one clause per failed
constraint at the member path, and two clauses share one message.

So a name of 128 U+1F600 was refused as too long, where DynamoDB
reports the pattern alone. A name of two U+1F600 got the pattern clause
alone, where DynamoDB also reports the length.

validate_index_name now takes the member path and calls
validate_name_member, which moves from the engine's backup module to
core. Each caller passes the path of its member. CreateTable passes it
for each GSI, LSI and vector index. UpdateTable passes it for each
GlobalSecondaryIndexUpdates action and each VectorIndexUpdates action.

DynamoDB lists the two clauses in either order. ExtendDB writes the
length clause first, as it does for table names. Measured in us-east-1
on 2026-11-06, 2026-11-14 and 2026-11-18.

Fixes #1021.
Fixes #904.
RestoreTableFromBackup did not check the IndexName of a
GlobalSecondaryIndexOverride or LocalSecondaryIndexOverride entry. It
looked the name up in the backup and refused a name the backup did not
hold with its own text. DynamoDB checks the name against the model's
constraints, 3 to 255 characters of [a-zA-Z0-9_.-], at the entry's
member path. It reports each failed constraint, as for a CreateTable
index.

DynamoDB checks the names after the account of BackupArn and after
TargetTableName, and before it reads the backup. A bad name with
another account's BackupArn gets AccessDeniedException. A bad name with
a TargetTableName of two characters gets the fault of the target name.
A bad name with a backup that does not exist gets the fault of the name.

The restore now checks each entry's IndexName with validate_index_name
after TargetTableName and before the backup is read. The fault is at
globalSecondaryIndexOverride.<n>.member.indexName or
localSecondaryIndexOverride.<n>.member.indexName, numbered from 1.

Measured in us-east-1 on 18 and 20 Nov 2026.

Fixes #1136.
#1009 moved `validate_name_member`, `table_name_bounds` and the other
request checks of `crates/engine/src/backup.rs` to
`crates/engine/src/backup_requests.rs`. This branch moved
`validate_name_member` to `extenddb_core::validation`, so the merge deletes
the copy in `backup_requests.rs` and imports the one in core in both files.
The `table_name_bounds` doc change moves with the function.
an_index_name_is_refused_at_its_member_path built its expected text
with validation_errors, the function that validate_name_member calls to
write the message. A fault in validation_errors would change both sides
of the assertion, and the test would pass. The test now writes the
sentence itself, as the core test does.
The index override check in step (3) left a short line in the middle of
the paragraph. The words do not change.

@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 the test does not check that the catalog index is left unread. source_reads in Fake counts only restore_source, the legacy reader. When I moved index_overrides.check_index_names()?; to just after read_catalog_row, an_index_override_name_is_checked_before_the_backup_is_read still passed. Removing the call, or placing it before the BackupArn check or before the target name check, fails it as the description says. Could you count read_backup_row calls in Fake and assert zero there too?

The wasm check fails at this head on web_time::Instant against std::time::Instant in crates/core/src/metrics/collector.rs:60, which #1482 fixed on main. The branch holds main at 5252eda and main is 14 commits ahead. I merged current main into this head locally: no conflict, the engine and core lib tests pass, and tests/test_backup_restore_fidelity.py plus tests/python/test_warm_throughput_backup.py pass on SQLite (38). Could you merge main so CI runs on that tree?

A question on the order: the name check runs after the override parse, so a bad BillingModeOverride or a missing BackupArn wins over a bad override name. With BillingModeOverride BOGUS and an override name g i, ExtendDB answers only the billingModeOverride enum fault, and with no BackupArn only the backupArn null fault. #1227 shows DynamoDB lists the name faults of both lists in one answer. Has anyone sent these two requests to DynamoDB, to see whether it lists the name fault beside the other one?

I will approve once the test counts the catalog read and CI is green on a branch with main merged.

Base automatically changed from fix/1021-index-name-length to main December 2, 2026 22:04
…override names

The test counted only the reads of the legacy reader, restore_source.
With the name check moved after read_catalog_row, it still passed. It
now also checks that the fake records no read_backup_row call.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  • The catalog read: 26dcbe1. The fake already records each read_backup_row call, and an_index_override_name_is_checked_before_the_backup_is_read now asserts that the restore made none. With the name check moved to directly after read_catalog_row, the test fails at its first row.

  • main: a31f385 merges main at b3510a9 with no conflict. fix(core): count an index name in characters and report its member path #1137 merged on 2 December, so the base of this PR is now main, and CI runs on that tree after the push.

  • The order question: DynamoDB answered both requests on 3 December 2026 in us-east-1, each sent twice, for a backup that does not exist.

    • BillingModeOverride BOGUS with a GSI override named g i: 2 validation errors detected: Value 'BOGUS' at 'billingModeOverride' failed to satisfy constraint: Member must satisfy enum value set: [PROVISIONED, PAY_PER_REQUEST]; Value 'g i' at 'globalSecondaryIndexOverride.1.member.indexName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+.
    • No BackupArn with the same override: Invalid Backup ARN alone.

    So DynamoDB answers an absent BackupArn before the override names, in the order of this PR, and fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327 changes the text of that answer to Invalid Backup ARN. DynamoDB lists the name fault beside the enum fault. ExtendDB answers the enum fault alone, because the engine checks the override values before the names. RestoreTableFromBackup checks an override value before the BackupArn and the TargetTableName length, where DynamoDB checks those first #1271 tracks that order, and a comment there now gives both requests.

Comment thread crates/engine/src/backup/tests.rs Fixed
…ssage

CodeQL reads the account of a test BackupArn in an assertion message as
cleartext logging of sensitive information (alert 259). The message of
the assertion in
an_index_override_name_is_checked_before_the_backup_is_read now names
the field, the index name and the target. The compared values still
show the row that fails.

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

No open points on this PR at 6194166.

The catalog read is covered. With index_overrides.check_index_names()?; moved to just before let mut legacy = None;, an_index_override_name_is_checked_before_the_backup_is_read now fails at the new row_reads assertion, where before it passed. Removing the call, or putting it before the BackupArn check or before the target name check, still fails it. You are right that the fake already recorded read_backup_row; the gap was only that the test did not assert on it.

CI is green on this head after the merge of main, 70 of 70 checks including wasm. Main as it is now merges into this head with no conflict. On SQLite the head passes the engine lib tests (981), tests/test_backup_restore_fidelity.py and tests/python/test_warm_throughput_backup.py, and a bad override name keeps its texts and member paths for the first and the second entry, with an existing backup and with a missing one.

On the order, your measurements settle my question. An absent BackupArn is answered before the override names, as this PR does. For BillingModeOverride BOGUS with g i, DynamoDB lists the enum fault and the name fault in one answer, and ExtendDB answers the enum fault alone. I see the same, because the restore parses the override values at step 1, before the names. That is #1271, not this change.

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.

RestoreTableFromBackup does not check the IndexName of an index override, which DynamoDB checks before it reads the backup

3 participants