test: add AWS XKS CI test against remote server - #1114
Open
p0wline wants to merge 3 commits into
Open
Conversation
p0wline
force-pushed
the
feat/ci-xks-remote
branch
from
August 14, 2026 14:06
32abf5e to
043c5da
Compare
p0wline
force-pushed
the
feat/ci-xks-remote
branch
2 times, most recently
from
September 2, 2026 08:57
00a4b94 to
757474b
Compare
|
Macroscope has since reviewed this pull request. An earlier review was skipped by a cost limit; a review has now completed, so that notice no longer applies. |
Manuthor
force-pushed
the
feat/ci-xks-remote
branch
from
September 3, 2026 10:05
757474b to
8c180dc
Compare
Manuthor
force-pushed
the
feat/ci-xks-remote
branch
from
September 3, 2026 12:41
8c180dc to
63142f9
Compare
Manuthor
force-pushed
the
feat/ci-xks-remote
branch
2 times, most recently
from
September 3, 2026 12:57
eefdf45 to
fa66ce8
Compare
Manuthor
added a commit
that referenced
this pull request
Sep 3, 2026
Pin dtolnay/rust-toolchain to a reviewed commit SHA instead of the mutable @master ref (CWE-829), and gate the secrets-bearing xks-remote job behind a GitHub Environment requiring manual reviewer approval before any same-repository PR can access KMS_XKS_SSH_PRIVATE_KEY / AWS credentials (CWE-284). Maintainers must configure required reviewers on the xks-remote-approval environment in repo Settings > Environments. Addresses PR #1114 review comments 3923422441 and 3924659091.
Manuthor
added a commit
that referenced
this pull request
Sep 3, 2026
…gration migrate_aws_xks_key_access wrapped kms_server.params.default_username in UserId::from(...) before comparing it to AWS_XKS_SERVICE_USER. UserId's From<&str> impl carries a debug_assert!(!s.is_empty()), which is reachable (CWE-617) because ServerParams derives Default and default_username defaults to an empty string — a valid configuration in debug/test builds. Compare the raw &str directly instead of constructing a UserId on this path. Also drops a duplicate AWS_XKS_SERVICE_USER import on the same use line. Adds a regression test asserting the migration succeeds for an empty default_username, which required fixing a pre-existing compile error in aws_xks/tests.rs (UserId::from(owner) where owner is already &UserId) that was otherwise blocking the whole crate's --tests target. Addresses PR #1114 review comment 3924659097.
Manuthor
added a commit
that referenced
this pull request
Sep 3, 2026
This PR's switch from scratchstack_aws_signature::sigv4_verify (previously hardcoded to Duration::minutes(5)) to sigv4_validate_request silently widened the accepted request-timestamp skew to that crate's internal 15-minute default, tripling the window during which a captured XKS SigV4 request remains replayable (CWE-294, OWASP A07:2021). The pinned scratchstack-aws-signature 0.11.4 exposes no public API to configure this: SignatureOptions has no allowed_mismatch field and sigv4_validate_request hard-codes ALLOWED_MISMATCH_MINUTES = 15 internally. Add an explicit 5-minute freshness check that parses the signed request timestamp (X-Amz-Date header, X-Amz-Date query parameter, or Date header) and rejects requests outside that window with AuthenticationFailedException before delegating to sigv4_validate_request for signature verification. Adds unit tests for timestamp extraction and freshness boundary/rejection. Addresses PR #1114 review comment 3924659101.
Manuthor
had a problem deploying
to
xks-remote-approval
September 3, 2026 13:39 — with
GitHub Actions
Failure
Manuthor
had a problem deploying
to
xks-remote-approval
September 3, 2026 14:06 — with
GitHub Actions
Failure
Manuthor
added a commit
that referenced
this pull request
Sep 3, 2026
Pin dtolnay/rust-toolchain to a reviewed commit SHA instead of the mutable @master ref (CWE-829), and gate the secrets-bearing xks-remote job behind a GitHub Environment requiring manual reviewer approval before any same-repository PR can access KMS_XKS_SSH_PRIVATE_KEY / AWS credentials (CWE-284). Maintainers must configure required reviewers on the xks-remote-approval environment in repo Settings > Environments. Addresses PR #1114 review comments 3923422441 and 3924659091.
Manuthor
added a commit
that referenced
this pull request
Sep 3, 2026
…gration migrate_aws_xks_key_access wrapped kms_server.params.default_username in UserId::from(...) before comparing it to AWS_XKS_SERVICE_USER. UserId's From<&str> impl carries a debug_assert!(!s.is_empty()), which is reachable (CWE-617) because ServerParams derives Default and default_username defaults to an empty string — a valid configuration in debug/test builds. Compare the raw &str directly instead of constructing a UserId on this path. Also drops a duplicate AWS_XKS_SERVICE_USER import on the same use line. Adds a regression test asserting the migration succeeds for an empty default_username, which required fixing a pre-existing compile error in aws_xks/tests.rs (UserId::from(owner) where owner is already &UserId) that was otherwise blocking the whole crate's --tests target. Addresses PR #1114 review comment 3924659097.
Manuthor
added a commit
that referenced
this pull request
Sep 3, 2026
This PR's switch from scratchstack_aws_signature::sigv4_verify (previously hardcoded to Duration::minutes(5)) to sigv4_validate_request silently widened the accepted request-timestamp skew to that crate's internal 15-minute default, tripling the window during which a captured XKS SigV4 request remains replayable (CWE-294, OWASP A07:2021). The pinned scratchstack-aws-signature 0.11.4 exposes no public API to configure this: SignatureOptions has no allowed_mismatch field and sigv4_validate_request hard-codes ALLOWED_MISMATCH_MINUTES = 15 internally. Add an explicit 5-minute freshness check that parses the signed request timestamp (X-Amz-Date header, X-Amz-Date query parameter, or Date header) and rejects requests outside that window with AuthenticationFailedException before delegating to sigv4_validate_request for signature verification. Adds unit tests for timestamp extraction and freshness boundary/rejection. Addresses PR #1114 review comment 3924659101.
Manuthor
force-pushed
the
feat/ci-xks-remote
branch
from
September 3, 2026 15:19
4606856 to
15445a7
Compare
Manuthor
had a problem deploying
to
xks-remote-approval
September 3, 2026 15:19 — with
GitHub Actions
Failure
Manuthor
had a problem deploying
to
xks-remote-approval
September 3, 2026 17:04 — with
GitHub Actions
Failure
Manuthor
had a problem deploying
to
xks-remote-approval
September 3, 2026 19:12 — with
GitHub Actions
Failure
Manuthor
had a problem deploying
to
xks-remote-approval
September 3, 2026 20:28 — with
GitHub Actions
Failure
Manuthor
had a problem deploying
to
xks-remote-approval
September 3, 2026 20:34 — with
GitHub Actions
Failure
Manuthor
force-pushed
the
feat/ci-xks-remote
branch
from
September 3, 2026 20:47
9fbd3fd to
8b17f19
Compare
Manuthor
force-pushed
the
feat/ci-xks-remote
branch
from
September 4, 2026 04:57
8b17f19 to
656dc76
Compare
Manuthor
force-pushed
the
feat/ci-xks-remote
branch
from
September 4, 2026 04:59
656dc76 to
7c647ae
Compare
Manuthor
force-pushed
the
feat/ci-xks-remote
branch
from
September 4, 2026 14:14
7c647ae to
a147c92
Compare
| .checked_add_signed(allowed_mismatch) | ||
| .unwrap_or(server_timestamp); | ||
|
|
||
| if request_timestamp < min_timestamp || request_timestamp > max_timestamp { |
There was a problem hiding this comment.
🟠 High aws_xks/sigv4_middleware.rs:282
A request queued on SIGV4_VERIFICATION_PERMITS can pass the five-minute freshness check after that window has expired, weakening the anti-replay control. server_timestamp is captured before permit acquisition and reused by both enforce_sigv4_request_freshness and sigv4_validate_request; capture the current time after acquiring the permit or immediately before validation.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @crate/server/src/routes/aws_xks/sigv4_middleware.rs around line 282:
A request queued on `SIGV4_VERIFICATION_PERMITS` can pass the five-minute freshness check after that window has expired, weakening the anti-replay control. `server_timestamp` is captured before permit acquisition and reused by both `enforce_sigv4_request_freshness` and `sigv4_validate_request`; capture the current time after acquiring the permit or immediately before validation.
Manuthor
force-pushed
the
feat/ci-xks-remote
branch
from
September 5, 2026 07:25
a147c92 to
65b72e5
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Context
Before this PR, XKS tests only ran locally against a mock server. There was no way to catch regressions in the full AWS integration path.
What this PR does
1. scratchstack 0.10 → 0.11 migration
The SigV4 verification library rejected secret keys longer than 43 characters. Version 0.11 removes that restriction, which was blocking the real AWS infrastructure (key was 52 chars).
2. CI workflow
.github/workflows/test_xks_remote.ymlOn every PR and push:
non-fipsrelease binaryaws-xks-kms.cosmian.dev) via SSHaws_xks_kek,encrypt_only_key,decrypt_only_key), enforces usage restrictions (encrypt-only / decrypt-only), then runs the vendored AWS XKS curl test suite directly against the server using SigV4 — no AWS KMS involvedaws kms encrypt/aws kms decryptvia the real AWS KMS API, which routes through the configured external key store to our proxy — verifies the full chain from AWS to Cosmian KMS and back3. Cherry-pick of
a14031598(fix: create a dedicated AWS-XKS user)Pulled in from your
fix/xks_permissionsbranch. The server now uses the reserved identity[aws-xks-service]for all XKS operations instead ofawsPrincipalArnfrom the request body. This is required for the end-to-end test to work: when AWS KMS calls the proxy, the injected ARN varies per caller, but[aws-xks-service]gets a single permanent grant at startup on every XKS key.4.
test_datasubmodule updatePoints to
fix/xks-config-env-overridewhich fixesconfig.shto respect env vars (see test_data PR #13). Without this, the vendored test suite ignored the SigV4 credentials injected by the CI workflow.5.
lychee.tomlAdded
kms\.example\.comandkms\.different\.comto the link-checker exclusions — these are fictional hostnames used in unit tests insidestart_kms_server.rsand were causing lychee to fail on every commit.Required GitHub secrets (repo Cosmian/kms)
AWS_XKS_ACCESS_KEY_IDaws kms encrypt/decrypt(xks-test user)AWS_XKS_SECRET_ACCESS_KEYAWS_XKS_KEY_ARNKMS_XKS_SIGV4_ACCESS_KEY_IDKMS_XKS_SIGV4_SECRET_ACCESS_KEYKMS_XKS_SSH_PRIVATE_KEYKMS_XKS_SSH_KNOWN_HOSTSaws-xks-kms.cosmian.devKMS_XKS_SSH_USERNote
Add remote AWS XKS CI test and harden
Sigv4Middlewarewith scratchstack 0.11aws_xks.Sigv4Middleware.callfrom the synchronous scratchstack 0.10 API to the 0.11 validator with a localSigningKeyService; request verification now runs in Tokio's blocking pool with a CPU-sized semaphoreenforce_sigv4_request_freshnessto reject requests outside a five-minute replay window, with timestamp extraction fromX-Amz-Dateheader,Dateheader, orX-Amz-Datequery parameterMacroscope summarized 65b72e5.