-
Notifications
You must be signed in to change notification settings - Fork 2
fix(xtest): rename policy binding assertions to reflect tamper classification #422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marythought
wants to merge
4
commits into
main
Choose a base branch
from
fix/xtest-kas-error-reclassify
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+45
−14
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c4180d2
fix(xtest): rename policy binding assertions to reflect tamper classi…
marythought 8ace857
docs(xtest): add instructions for running xtests against platform fea…
marythought 92f942c
fix(xtest): tighten policy tamper assertion for SDKs with tamper-erro…
marythought b6ba5bb
Merge branch 'main' into fix/xtest-kas-error-reclassify
dmihalcik-virtru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -565,30 +565,38 @@ def assert_tamper_error( | |
| ) | ||
|
|
||
|
|
||
| def assert_kas_request_error( | ||
| def assert_policy_tamper_error( | ||
| exc: subprocess.CalledProcessError, decrypt_sdk: tdfs.SDK | ||
| ) -> None: | ||
| """Assert that a KAS request error was returned. | ||
| """Assert that a policy binding tamper error was returned. | ||
|
|
||
| Used for policy binding failures where KAS rejects the request (400). | ||
| Accepts both the new error classification (KAS request error) and the | ||
| legacy classification (tamper) for backward compatibility with older | ||
| SDK versions. | ||
| Policy binding failures (unbound or altered policy) are integrity | ||
| failures. KAS intentionally returns a generic "bad request" to avoid | ||
| leaking information about secret key computations, and the SDK | ||
| classifies this as a tamper error. | ||
| """ | ||
| if decrypt_sdk.supports("tamper-error-split"): | ||
| # SDK distinguishes tamper from misconfiguration — assert tamper specifically | ||
| assert re.search(b"tamper", exc.output, re.IGNORECASE), ( | ||
| f"Expected tamper error, got: [{exc.output}]" | ||
| ) | ||
| assert not re.search(b"KAS request error", exc.output, re.IGNORECASE), ( | ||
| f"Policy binding failure must not be classified as KAS request error: [{exc.output}]" | ||
| ) | ||
|
Comment on lines
+578
to
+585
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Broaden the strict-mode negative match for request-error classification tokens. This currently forbids only Proposed patch- assert not re.search(b"KAS request error", exc.output, re.IGNORECASE), (
+ forbidden = b"|".join(
+ re.escape(p)
+ for p in [b"KAS request error", b"KASRequestError", b"ErrKASRequestError"]
+ )
+ assert not re.search(forbidden, exc.output, re.IGNORECASE), (
f"Policy binding failure must not be classified as KAS request error: [{exc.output}]"
)🤖 Prompt for AI Agents |
||
| return | ||
|
|
||
| # Older SDKs: accept any plausible error output | ||
| expected_patterns = [ | ||
| # New classification: KAS request error | ||
| b"KAS request error", | ||
| b"rewrap request 400", | ||
| b"tamper", | ||
| b"bad request", | ||
| b"InvalidArgument", | ||
| # Legacy classification: tamper (older SDK versions) | ||
| b"tamper", | ||
| b"rewrap request 400", | ||
| b"InvalidFileError", | ||
| b"could not find policy in rewrap response", | ||
| ] | ||
| pattern = b"|".join(re.escape(p) for p in expected_patterns) | ||
| assert re.search(pattern, exc.output, re.IGNORECASE), ( | ||
| f"Expected KAS request or tamper error, got: [{exc.output}]" | ||
| f"Expected policy tamper error, got: [{exc.output}]" | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -628,7 +636,7 @@ def test_tdf_with_unbound_policy( | |
| decrypt_sdk.decrypt(b_file, rt_file, "ztdf", expect_error=True) | ||
| assert False, "decrypt succeeded unexpectedly" | ||
| except subprocess.CalledProcessError as exc: | ||
| assert_kas_request_error(exc, decrypt_sdk) | ||
| assert_policy_tamper_error(exc, decrypt_sdk) | ||
|
dmihalcik-virtru marked this conversation as resolved.
|
||
|
|
||
| # Verify rewrap failure was logged (policy binding mismatch) | ||
| # FIXME: Audit logs are not present on failed bindings | ||
|
|
@@ -669,7 +677,7 @@ def test_tdf_with_altered_policy_binding( | |
| decrypt_sdk.decrypt(b_file, rt_file, "ztdf", expect_error=True) | ||
| assert False, "decrypt succeeded unexpectedly" | ||
| except subprocess.CalledProcessError as exc: | ||
| assert_kas_request_error(exc, decrypt_sdk) | ||
| assert_policy_tamper_error(exc, decrypt_sdk) | ||
|
dmihalcik-virtru marked this conversation as resolved.
|
||
|
|
||
| # Verify rewrap failure was logged (policy binding mismatch) | ||
| # FIXME: Audit logs are not present on failed bindings | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.