Skip to content

fix(authz): authorize SearchVectors against the vector index ARN - #999

Merged
LeeroyHannigan merged 4 commits into
mainfrom
fix/authz-search-vectors-index
Nov 17, 2026
Merged

LeeroyHannigan merged 4 commits into
mainfrom
fix/authz-search-vectors-index

Conversation

@navareamol

@navareamol navareamol commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What this changes

SearchVectors was authorized against the table ARN. The DynamoDB developer guide documents table/<T>/index/<I> as the resource for dynamodb:SearchVectors, the same as Query and Scan with an IndexName. So a Deny on the vector index (table/<T>/index/<I> or table/<T>/index/*) never matched, and the search ran.

SearchVectors now takes the same index path as Query and Scan in authz_targets.

Workflow

SearchVectors(TableName, IndexName)
   -> build target: table/<T>/index/<I>      (was: table/<T>)
   -> policy match on the index ARN
   -> tags are read from the base table
   -> allowed: engine searches that index

Policy behavior that changes

This is a behavior change. Please read it before approving.

Policy Before After
Deny on table/T/index/I or table/T/index/* Did not block the search Blocks it
Allow only on table/T Permitted SearchVectors No longer permits it. Needs table/T/index/I or table/T/index/*.
Deny only on table/T Blocked SearchVectors No longer blocks it. Fencing a table needs table/T/* too.
Allow or Deny on * Applied Applies, as before

The admin guide lists the new resource and both effects.

Use cases handled

  • Deny on a specific vector index: the search is refused.
  • Deny on table/T/index/*: every vector index of the table is refused.
  • Deny on another index: this index still works.
  • Allow on the table's indexes only: the search works.
  • No IndexName: authorized against the table, as before.
  • IndexName outside [a-zA-Z0-9_.-]+ (extra slashes, spaces, %2f, NUL): refused with the same pattern ValidationException as Query and Scan, before the permission check. SearchVectors is now in the "Query" | "Scan" arm of table_name_gate.rs. Without that, a denied caller would get AccessDeniedException where main gave a ValidationException. Like Query, the gate checks the pattern only; the length rules for an index name are not measured.
  • TableName given as a full table ARN: the denial names the ARN with the index appended.

Failure cases and limits

  • Not measured on live DynamoDB. The match to the developer guide comes from the documentation. Nobody has checked what the service does with a Deny or Allow written only on table/T for SearchVectors. If the service does apply a table-only Deny, this PR loosens that Deny. Please say here if anyone can measure it.
  • The error order on the live service is not measured. Whether DynamoDB answers the pattern failure or the permission failure first for SearchVectors is unknown. This PR follows Query and Scan.
  • A SearchVectors request that names a table in another account is refused with the resource table/<T>/index/<I> in the denial, as Query and Scan do. The refusal itself is unchanged. A request with no IndexName, or an empty one, still names the table.
  • Existing deployments with table-only Allow policies lose SearchVectors until the policy names the index.
  • Not run: Cassandra and MongoDB. No storage code is touched.

Testing

  • Rust unit tests on the derived targets, including adversarial IndexName values (3 tests in search_vectors_tests.rs).
  • Wire tests in tests/test_authz_search_vectors_index.py against a running server: Deny on the index, on the wildcard, on the bare table ARN, on another index; Allow on only the bare table ARN (refused); Allow on the table's indexes (permitted). They check the error type, not the message. 75 pass on SQLite and 75 on PostgreSQL across the three authz test files.
  • Negative control: with authz_resource.rs restored to the base, 5 vector tests fail, including both table-ARN tests.
  • cargo fmt --check, clippy 1.97 with -D warnings, build on 1.88: clean. 507 server unit tests pass.
  • Hostile review: odd index names, other-account and other-region ARNs, and condition forms. Nothing got past a Deny on the index.

Docs

docs/manuals/05-admin-guide.md: the resource for SearchVectors, the "Fencing a whole table with a Deny" bullet, the resource-tags bullet, and the "Index reads" bullet. docs/manuals/07-upgrade-manual.md: three behavior-change items now name SearchVectors, so a table-only Allow losing SearchVectors at upgrade is listed.

The DynamoDB developer guide documents table/<T>/index/<I> as the resource
for dynamodb:SearchVectors: a search is authorized against the vector index
it reads, as Query and Scan with an IndexName are. This match comes from the
developer guide. It has not been measured against the live service.

ExtendDB sent SearchVectors through the generic single-table path, which
authorized the table ARN. A Deny on table/<T>/index/<I>, or on
table/<T>/index/*, never matched, and the search ran.

SearchVectors now takes the Query and Scan index path in authz_targets: the
policy match uses the canonical index ARN, the denial names the TableName as
written with the index appended when TableName is a table ARN, and resource
tags are read from the base table. An IndexName that is not one index segment
is authorized as written, so a Deny on table/<T>/index/* refuses it, and no
vector index can carry such a name, so the engine finds no index to search.

This changes policy behavior in two ways. Existing policies that allow
SearchVectors only on table/<T> stop permitting it and now need
table/<T>/index/<I> or table/<T>/index/*. A Deny written only on table/<T>
no longer blocks SearchVectors; fencing a table needs table/<T>/* as well.
The admin guide lists the new resource and both effects.

Verified with Rust unit tests on the derived targets, including adversarial
IndexName values, and wire tests against a running server: a principal with
dynamodb:* plus a Deny on the vector index, on the index wildcard, on the
bare table ARN, or on another index; and an Allow on only the bare table ARN
(refused) or on the table's indexes (permitted). The wire tests check the
refusal by error type.
@navareamol navareamol added this to the 1.0 milestone Nov 16, 2026
@navareamol navareamol added security v1 Needed for the 1.0 release labels Nov 16, 2026
@navareamol navareamol added the release-blocker Must ship for its milestone's release label Nov 16, 2026
@navareamol navareamol self-assigned this Nov 16, 2026

@LeeroyHannigan LeeroyHannigan 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 built this branch, ran the SearchVectors authorization tests on SQLite and PostgreSQL with vector indexes enabled, ran the IndexName and policy cases as probes on both, and checked the change against the admin guide, the upgrade manual and the other open PRs.

What I ran

  • The 3 unit tests and the 7 wire tests in tests/test_authz_search_vectors_index.py pass on SQLite and on PostgreSQL with EXTENDDB_EXPECT_VECTORS=1. Reverting the one-line change fails 5 of the 7 wire tests and 2 unit tests, so the tests catch the fix. fmt, clippy 1.97 with -D warnings, and the 1.88 build are clean, and CI is 58 of 58.
  • The derived resource for a SearchVectors with an IndexName is table/<T>/index/<IndexName>, and the resource tags resolve to the base table. Both hold on a run, on both backends.

Before merge

  1. A SearchVectors IndexName outside [a-zA-Z0-9_.-]+ reaches the IAM decision, while Query and Scan refuse it first. crates/server/src/table_name_gate.rs checks the IndexName pattern for Query and Scan ahead of the policy decision, because the service answers a member-pattern failure before the IAM decision (the change in #830). SearchVectors is not in that arm, so with this PR a caller with a Deny on table/T/index/*, or one allowed only table/T, gets AccessDeniedException for an IndexName like vidx/extra, where Query gets the pattern ValidationException at indexName and main returned a ValidationException. The SearchVectors API reference gives its IndexName the same pattern and length as Query. I could not call SearchVectors against the live service from here, so the error order the service uses for SearchVectors is unmeasured: if the service answers the pattern failure first, this is a client-visible change the PR introduces; if it answers AccessDeniedException, it is an inconsistency with Query and Scan on our own server. Routing SearchVectors through the same gate arm is the safe fix either way, and the slash test should then expect that ValidationException for both callers. As written, test_index_name_with_a_slash_is_authorized_as_written asserts the AccessDeniedException and cements the divergence. The inline comment on authz_resource.rs has the measured responses.

Minor

  • crates/server/src/authz_resource.rs:765: the arm comment says a SearchVectors request names a vector index, but the arm authorizes the table when IndexName is missing or empty, which the second unit test asserts and a run confirms.
  • docs/manuals/05-admin-guide.md:750: the resource-tags bullet names only Query and Scan; SearchVectors reads the base table's tags too, confirmed by an ABAC run on both backends. The "follows the DynamoDB developer guide" sentence at 736 now also covers Query and Scan, which were measured against the service; only the SearchVectors resource rests on the developer guide. The upgrade manual's "Index reads need an index grant" item (docs/manuals/07-upgrade-manual.md:794) names only Query and Scan and gains no entry for the SearchVectors change, so a table-only Allow loses SearchVectors at upgrade with nothing in the behaviour-change list.
  • The 7 wire cases are one function per policy row; one parametrized table over (effect, resource, status, error type) would be shorter (code-size rule 4), and _expect_vectors is copied from tests/test_search_vectors_condition_limit.py.

Checked and matched the documentation

  • The resource table/<T>/index/<I> for dynamodb:SearchVectors matches the AWS developer guide and the IAM policy example page. SearchVectors reuses the Query and Scan authorization path, with no second copy. An adversarial IndexName (a slash, %2f, NUL, a trailing space) named no real index on either backend and never returned 200. The change shares no file with #998 or #1000.

// names that ARN with the index appended; any other ARN in TableName
// (an index ARN, a malformed resource) names the canonical index ARN,
// so the denial never names a resource the caller did not write.
"Query" | "Scan" | "SearchVectors" => {

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.

Query and Scan refuse an IndexName outside [a-zA-Z0-9_.-]+ in table_name_gate.rs before the IAM decision (the change in #830). SearchVectors is not in that arm, so with this change an IndexName like vidx/extra goes into the resource as sent and a caller with a Deny on table/T/index/*, or one allowed only table/T, gets AccessDeniedException. On a run (both backends) Query answered ValidationException ... at 'indexName' ... pattern: [a-zA-Z0-9_.-]+ for the same value, and main returned a ValidationException here. The SearchVectors API reference gives IndexName the same pattern and length. I could not call SearchVectors against the live service to settle which error it returns first, so this is at least an inconsistency with Query and Scan on our server, and a client-visible change if the service answers the pattern failure first. Adding SearchVectors to the "Query" | "Scan" arm of the gate reuses the pattern check, and the slash test would then expect the ValidationException for both the denied and the allowed caller.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c6a2700. SearchVectors now takes the "Query" | "Scan" arm in table_name_gate.rs, so vidx/extra gets the pattern ValidationException at indexName before the IAM decision, for every caller. Like Query, the gate checks the pattern only, because the length rules for an index name are unmeasured.

Evidence, with EXTENDDB_EXPECT_VECTORS=1: the three authz wire files pass on SQLite and PostgreSQL (78 each). The slash test, renamed test_index_name_outside_the_pattern_is_refused_before_authorization, now expects ValidationException for both the allow-all caller and the caller with a Deny on table/T/index/*. A unit test compares SearchVectors with Query for vidx/extra, NUL, a space and %2f. With the gate change reverted, the Deny-on-index-wildcard case fails (1 failed, 9 passed). The allow-all case passes either way, because the engine already answers ValidationException.

I did not call SearchVectors on the live service, so which error it returns first is still unmeasured. This change makes ExtendDB consistent with Query and Scan, and matches main's ValidationException for a bad name.

Amol Navare added 2 commits November 16, 2026 17:47
Query and Scan refuse an IndexName outside [a-zA-Z0-9_.-]+ with a
ValidationException at indexName before the policy decision, because the
service answers a member-pattern failure before the IAM decision. SearchVectors
was not in that check, so an IndexName such as vidx/extra reached the policy:
a caller with a Deny on table/<T>/index/*, or one allowed only table/<T>, got
AccessDeniedException where Query answers ValidationException. Whether the
service orders the errors the same way for SearchVectors has not been measured;
the SearchVectors API reference gives IndexName the same pattern as Query.

SearchVectors now takes the Query and Scan arm of the name gate, so every
caller gets the same ValidationException. The gate checks the pattern only, as
it does for Query: the length rules for an index name are unmeasured.

Also correct the arm comment in authz_resource.rs (a request with no IndexName
authorizes the table), state in the admin guide that only the SearchVectors
resource rests on the developer guide, name SearchVectors in the resource-tags
bullet, and add the SearchVectors change to the upgrade manual: a table-only
Allow loses SearchVectors, and a table-only Deny no longer blocks it.

The wire tests are one parametrized table over (effect, resource, status, error
type) plus the IndexName cases, and reuse _expect_vectors. A unit test covers
the gate for SearchVectors. Wire tests assert the error type, not the message.
@navareamol

Copy link
Copy Markdown
Collaborator Author

Pushed c6a2700 and dfb32f3 on top of 145a4a2, no force-push. The minor items:

  • The arm comment in authz_resource.rs now says a missing or empty IndexName authorizes the table.
  • The admin guide's resource-tags bullet names SearchVectors, and the "follows the developer guide" sentence now covers only the SearchVectors resource.
  • The upgrade manual lists the table-only Allow and Deny changes.
  • The wire cases are one parametrized table, and _expect_vectors is imported from test_search_vectors_condition_limit.py.

The PR description lists the pattern check and the unmeasured error order.

…nial

A SearchVectors request that names a table in another account is refused
either way, but the denial named table/<T> where Query and Scan name
table/<T>/index/<I>. The cross-account check read the resource for Query and
Scan only, so SearchVectors fell through to the table.

SearchVectors now takes the Query and Scan arm of the cross-account check, so
the denial names the vector index ARN, as the policy check already does. A
request with no IndexName still names the table. The service has no
SearchVectors answer to measure; it keeps the DescribeTable answers and only
the resource named changes.

Verified with a unit test on the resource found for a SearchVectors request
and the denial message it produces.

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

@navareamol Thanks for this. The core change is right. SearchVectors now authorizes against the vector index resource, so a Deny on table/<T>/index/<I> or table/<T>/index/* is enforced, and a table-only Deny no longer blocks the search. I confirmed a Deny on the index resource refuses the search where the base branch allowed it, that an Allow on only the table no longer permits it, and that no crafted IndexName or TableName ARN gets past a Deny on the index wildcard. SearchVectors now matches Query and Scan for allow, deny, and malformed index names.

I will approve once the cross-account path names the index resource too. In crates/server/src/authz_resource/cross_account.rs a SearchVectors request still falls through to the table resource, so a cross-account denial names table/<T> rather than table/<T>/index/<I>. The request is refused either way, but the resource in the message should match Query and Scan. Adding SearchVectors to the Query and Scan arm there is the change.

One item is out of scope for this PR and tracked in #1014: an index name shorter than 3 or longer than 255 is not refused before authorization, and that applies to Query and Scan as well.

@navareamol

Copy link
Copy Markdown
Collaborator Author

@eliseong Fixed in cc43a0b. SearchVectors is now in the "Query" | "Scan" arm of find() in cross_account.rs, so a cross-account denial names table/<T>/index/<I>, as the policy check already did. A request with no IndexName, or an empty one, still names the table.

A unit test, a_cross_account_search_vectors_names_the_index_arn, pins the resource find() returns and that the refusal message names the index ARN. With the cross_account.rs change reverted, it fails: the resource is .../table/t where .../table/t/index/vidx is expected. fmt, clippy 1.97 and the build are clean. extenddb-server unit tests: 509 passed. The authz wire tests with vectors enabled pass on SQLite and PostgreSQL (78 each).

The service has no SearchVectors answer I could measure, so SearchVectors keeps the DescribeTable answers and only the named resource changes. The PR description has the new line.

@LeeroyHannigan the earlier points from your review are in dfb32f3 and c6a2700. Could you re-review?

@navareamol
navareamol requested a review from eliseong November 17, 2026 07:38

@LeeroyHannigan LeeroyHannigan 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 re-reviewed at cc43a0b, built the branch, and ran the unit and wire tests. The round-1 items are resolved.

Verified

  • The gate: a SearchVectors IndexName outside [a-zA-Z0-9_.-]+ is now refused before the IAM decision, as Query and Scan are. table_name_gate.rs adds SearchVectors to that arm, and the new unit test checks that vidx/extra, a NUL, a space and %2f get the pattern ValidationException for SearchVectors and for Query alike. On a PostgreSQL server with vector indexes, vidx/extra returns ValidationException both for an allow-all caller and for a caller with a Deny on the index wildcard, so the error no longer depends on the policy.
  • The cross-account denial now names table/<T>/index/<I> for SearchVectors, with a unit test; a request with no IndexName names the table.
  • The arm comment no longer says SearchVectors always names an index. The admin guide's resource-tags and index-grant bullets name SearchVectors, the "follows the DynamoDB developer guide" sentence is scoped to the SearchVectors resource, and the upgrade manual lists the table-only Allow and Deny change. The wire cases are one parametrized table over the policy rows, and _expect_vectors is imported rather than copied.

Runs

  • Server unit tests for the gate, authz, cross-account and search paths: 27 pass, including search_vectors_index_name_outside_the_pattern_is_refused_as_query_is and a_cross_account_search_vectors_names_the_index_arn.
  • Authz wire tests on PostgreSQL with EXTENDDB_EXPECT_VECTORS=1: 10 pass. CI is 58 of 58.

Notes, not blocking

  • An IndexName shorter than 3 or longer than 255 is still not refused before authorization, for Query and Scan as well, which #1014 tracks.
  • The admin guide and upgrade manual edits touch files other open documentation PRs also edit, so a trivial rebase may be needed depending on merge order.

Merged via the queue into main with commit 85c5843 Nov 17, 2026
58 checks passed
@LeeroyHannigan
LeeroyHannigan deleted the fix/authz-search-vectors-index branch November 17, 2026 11:45
LeeroyHannigan added a commit that referenced this pull request Nov 17, 2026
docs/manuals/05-admin-guide.md keeps the bulk operations and resource tags entry from this branch. The entries around it take the SearchVectors index ARN text from main (#999).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-blocker Must ship for its milestone's release security v1 Needed for the 1.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants