Skip to content

acl-agent: pass Nebraska-reported hash to Trident as sha384 - #769

Open
bfjelds (bfjelds) wants to merge 2 commits into
mainfrom
user/bfjelds/acl-agent-verify-nebraska-hash
Open

acl-agent: pass Nebraska-reported hash to Trident as sha384#769
bfjelds (bfjelds) wants to merge 2 commits into
mainfrom
user/bfjelds/acl-agent-verify-nebraska-hash

Conversation

@bfjelds

@bfjelds bfjelds (bfjelds) commented Sep 2, 2026

Copy link
Copy Markdown
Member

Problem

trident-acl-agent never passed the Nebraska-reported package hash to Trident (update/update_stage were always called with hash: None), on the theory that Trident's own COSI metadata check made it redundant.

Our Nebraska deployment reports a base64-encoded SHA-384 of the COSI's metadata section in the Omaha hash attribute (the field/type Omaha calls sha1, but ours does not follow that convention) - the same value/algorithm Trident validates via image.sha384. So it can and should be forwarded.

Changes

  • PackageHash::to_cosi_sha384() (core/nebraska/client.rs): decodes the base64 value, requires exactly 48 bytes (SHA-384 digest size), hex-encodes it for Trident's gRPC image.sha384 field.
  • omahaonly/mod.rs and annotations/orchestrator.rs::handle_stage: pass the converted hash instead of None.
  • A missing or unusable hash is now a hard failure instead of a silently-skipped check:
    • omaha-only flow: anyhow! error.
    • annotation orchestrator: StatusCode::OperationFailed status write.
  • New workspace dependency: base64.

Testing

  • cargo check -p trident-acl-agent --all-targets
  • cargo clippy -p trident-acl-agent --all-targets -- -D warnings
  • cargo fmt -p trident-acl-agent -- --check
  • cargo test -p trident-acl-agent --lib (168 passed, incl. 3 new tests for to_cosi_sha384)
  • pr-e2e with commit targeting pr 731

@bfjelds
bfjelds (bfjelds) marked this pull request as ready for review September 3, 2026 23:25
Copilot AI lite review requested due to automatic review settings September 3, 2026 23:25
@bfjelds
bfjelds (bfjelds) requested a review from a team as a code owner September 3, 2026 23:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new hash decoding path should avoid potentially unbounded allocation on untrusted input, and the updated docs should be made internally consistent.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates trident-acl-agent to forward Nebraska’s reported package hash to Trident as a hex-encoded SHA-384 (matching Trident’s image.sha384 integrity check), and makes missing/unusable hashes a hard failure rather than silently skipping integrity verification.

Changes:

  • Add PackageHash::to_cosi_sha384() to convert Nebraska’s base64 “sha1” field into the hex SHA-384 string Trident expects.
  • Pass the converted hash into Trident update / update_stage calls in both the omaha-only and annotation-orchestrator flows, failing fast when absent/invalid.
  • Add the base64 workspace dependency (and hex dependency for trident-acl-agent) plus unit tests for the conversion.
File summaries
File Description
crates/trident-acl-agent/src/omahaonly/mod.rs Requires a Nebraska hash and forwards it to Trident’s one-shot update RPC.
crates/trident-acl-agent/src/core/nebraska/client.rs Adds base64→hex SHA-384 conversion helper + tests; documents Nebraska field repurposing.
crates/trident-acl-agent/src/annotations/orchestrator.rs Requires/validates hash early and forwards it to update_stage, emitting failure status on error.
crates/trident-acl-agent/Cargo.toml Adds base64 and hex dependencies via workspace.
Cargo.toml Adds base64 to [workspace.dependencies].
Cargo.lock Records the new dependency edges for trident-acl-agent.
Review details
  • Files reviewed: 5/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/trident-acl-agent/src/core/nebraska/client.rs
Comment thread crates/trident-acl-agent/src/core/nebraska/client.rs Outdated
trident-acl-agent previously never passed the Nebraska-reported package
hash to Trident, on the theory that Trident's own COSI metadata check
made it redundant. Our Nebraska deployment actually reports a
base64-encoded SHA-384 of the COSI metadata section in the field Omaha
calls sha1 (not a real SHA-1), which is the same value/algorithm
Trident validates via image.sha384 - so it can and should be used.

- Add PackageHash::to_cosi_sha384() to decode the base64 value and
  hex-encode it for Trident's gRPC image.sha384 field, requiring
  exactly 48 decoded bytes (SHA-384 digest size).
- Pass the converted hash from both the omaha-only flow and the
  annotation orchestrator's handle_stage, instead of None.
- Treat a missing or unusable hash as a hard failure: an anyhow error
  in the omaha-only flow, and a StatusCode::OperationFailed status
  write in the orchestrator, rather than silently skipping
  verification.
- Add base64 as a new workspace dependency for the decode step.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 3, 2026 23:38
@bfjelds
bfjelds (bfjelds) force-pushed the user/bfjelds/acl-agent-verify-nebraska-hash branch from fc40064 to 22f09f8 Compare September 3, 2026 23:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The functional changes are coherent and tested, with only a minor doc-comment wording issue noted.

Review details

Suppressed comments (1)

crates/trident-acl-agent/src/core/nebraska/client.rs:91

  • The doc comment says the Nebraska hashes “hash the file (not its contents)”, but this is confusing/incorrect—hashes are of bytes/content, and this module now explicitly documents that our deployment repurposes sha1 for a SHA-384 of the COSI metadata section. Reword this sentence to describe upstream semantics without the misleading “not its contents” phrasing.
/// Both values are base64-encoded and hash the *file* (not its contents).
/// Nebraska reports a SHA-1; `sha256` is present only when the file was
/// registered with one.
///
/// **Our Nebraska deployment does not follow that naming.** By internal
  • Files reviewed: 5/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

- Decode the Nebraska-reported hash directly into a fixed 48-byte
  buffer via decode_slice instead of Engine::decode's allocating
  Vec<u8> output, so an oversized base64 string is rejected without
  an allocation proportional to (untrusted) input size.
- Reword the PackageHash doc comment: "hash the file (not its
  contents)" was self-contradictory next to the following paragraph
  describing an actual content hash; state plainly that both fields
  are content hashes per upstream Omaha/Nebraska semantics.
- Add a regression test for the oversized-input case.
Copilot AI review requested due to automatic review settings September 4, 2026 14:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The hash forwarding/conversion logic matches Trident’s image.sha384 contract, is applied consistently across flows, and is covered by targeted unit tests.

Review details
  • Files reviewed: 5/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

bfjelds (bfjelds) added a commit that referenced this pull request Sep 4, 2026
Trident now requires trident-acl-agent to forward Nebraska's reported
package hash (#769), so the fake Nebraska proxy must seed a package hash
in its Omaha response or the stage operation fails with OperationFailed.

Reproduce the real deployment's quirk: base64-encode the COSI metadata
SHA-384 into the package hash field, matching what trident-acl-agent's
PackageHash::to_cosi_sha384 expects to decode.
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.

2 participants