Repository navigation
security(server): authenticate audit records with HMAC (#304) - #328
Draft
JeongWon4034 wants to merge 1 commit into
Draft
JeongWon4034 wants to merge 1 commit into
JeongWon4034 wants to merge 1 commit into
Conversation
| #[test] | ||
| fn rfc4231_sha256_vector() { | ||
| // https://www.rfc-editor.org/rfc/rfc4231.html#section-4.2 | ||
| let mut mac = Hmac::<Sha256>::new_from_slice(&[0x0b; 20]).unwrap(); |
| let expected = | ||
| hex::decode("e8fec96ef84c8203953e92a8795813659ee30a201f3784322da5a1153380cd10") | ||
| .unwrap(); | ||
| record_mac(&record, &[0xab; 32]) |
7 of 13 tasks
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.
Summary
Closes #304.
A log-file writer could edit audit records and recompute the entire unkeyed SHA-256 chain. Add opt-in HMAC-SHA256 authentication from server-owned configuration: recomputed forgeries, stripped authentication fields and wrong/unknown keys fail verification and prevent append.
GET /security/audit/chain; return HTTP 500 whenPOST /security/auditcannot persist a record.Type of change
feat:)fix:)docs:)Checklist
cargo fmt --all -- --checkpassescargo clippy --workspace --all-targets --locked -- -D warningspassescargo test --workspace --lockedpasses — 759 passed, 0 failed, 0 ignoredCHANGELOG.mdupdatedValidation
Windows GNU, Rust/Cargo 1.98.0; RTX 4070 Laptop GPU detected (driver 591.44).
CARGO_PROFILE_DEV_DEBUG=0andCARGO_PROFILE_TEST_DEBUG=0avoid the documented GNU executable-size limit. Default Cargo features; GPU acceptance was not enabled for this server-only change.Server coverage: 132 unit tests and 3 real-process HTTP tests. New checks include RFC 4231 and a Python HMAC golden, full-chain hash recomputation attacks, optional-field ambiguity, auth stripping, malformed tags, wrong/missing keys, rotation, legacy migration, failed-append preservation, startup/API rejection, and two server processes writing the same authenticated log. All logs/DBs are temporary; tests do not modify operator environment variables or runtime audit data.
Reproduction and evidence.
Notes for reviewers
Draft because the broader dependency gate is not green. With cargo-deny 0.20.2:
cargo deny --all-features checkpasses, but only covers the CLI graph.cargo deny --workspace --all-features checkreports 37 errors: 16 license rejections, 14 vulnerability diagnostics, 3 unsoundness, 2 unmaintained packages and 2 yanked versions.b347688produces identical error diagnostic counts and the same 19 RustSec IDs. No locked package version changed; the only lockfile change is the server's edge to already-lockedhmac 0.13.0.--workspace; its success must not be interpreted as full-workspace coverage. No advisory suppression or license-policy changes are included.HMAC assumes the file writer cannot read/change the server's keys or trusted configuration; environment injection alone does not enforce OS permissions. Valid-prefix rollback/tail truncation and external checkpoints remain #305. Legacy prefixes remain explicitly unauthenticated.