Skip to content

fix(desktop): attest proxy before sending admin token - #594

Open
luvs01 wants to merge 2 commits into
devfrom
codex/propose-fix-for-admin-token-leak
Open

luvs01 wants to merge 2 commits into
devfrom
codex/propose-fix-for-admin-token-leak

Conversation

@luvs01

@luvs01 luvs01 commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a local attacker that binds the discovered loopback port from provoking the desktop to disclose the file-backed admin token by returning a 401 and capturing the retry.
  • Ensure the desktop only releases the reusable management credential after the peer proves process-bound identity (PID/port) via the existing local HMAC attestation protocol.

Description

  • Add Auth::runtime_identity() that loads the protected runtime-port.json (pid/port/attestation secret) and validate its shape before use in the desktop client (desktop/src-tauri/src/auth.rs).
  • Before retrying a 401 with the admin token, call authenticate_target() to issue an x-opencodex-attestation-challenge to /healthz and verify the returned HMAC proof, service, pid, port, and that the runtime record remains unchanged (desktop/src-tauri/src/proxy.rs).
  • Implement constant-time HMAC verification using hmac + sha2 and Base64URL decoding to match the server attestation primitive and map request errors cleanly (desktop/src-tauri/src/proxy.rs).
  • Add a focused unit test asserting proof binding to the recorded runtime identity and add the required Rust deps to desktop/src-tauri/Cargo.toml (base64, hmac, sha2).

Testing

  • Ran bun run typecheck, which passed.
  • Ran cargo fmt --manifest-path desktop/src-tauri/Cargo.toml -- --check and git diff --check, which passed, and committed the changes.
  • Ran bun run privacy:scan, which passed.
  • Attempted cargo check --manifest-path desktop/src-tauri/Cargo.toml, which was blocked by the environment missing glib-2.0.pc required by Tauri on this CI container (external system dependency), so desktop cargo check could not complete here.
  • Ran bun run test until environment-driven server-test expectations diverged (existing unrelated failures where some fixtures returned 403 vs expected 401); many test cases executed and passed earlier in the run but the full suite was not completed in this environment.

Codex Task


Devin Review

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: d6ac994c-4728-46a2-966f-dd791bd473a2


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-21T01:30:11.047935Z f91d022 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the bug Something isn't working label Sep 21, 2026
@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

Comment thread desktop/src-tauri/src/proxy.rs
Comment on lines +82 to 84
self.authenticate_target().await?;
let token = self.auth.token().ok_or(ProxyError::Unauthorized)?;
let response = self.send(&method, path, Some(token)).await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Explicit security review is required before merge

This PR changes admin-token handling and an authentication boundary. Repository policy requires explicit security review and maintainer sponsorship before merge.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

The server signs proofs with createHmac("sha256", secret), which keys the
MAC with the Base64URL text's UTF-8 bytes. The desktop verifier decoded
the secret to its raw 32 bytes first, so every genuine proof failed and
authenticated tray, widget, and stop requests fell over. Use
identity.attestation_secret.as_bytes() and refresh the unit vector with
the proof the TypeScript primitive produces for the same inputs.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
@devin-ai-integration

Copy link
Copy Markdown

Fixed in 614ce62valid_attestation_proof now keys Hmac<Sha256> with identity.attestation_secret.as_bytes() (the encoded Base64URL text's UTF-8 bytes, matching createHmac("sha256", secret) on the server) instead of decoding first. The unit vector was regenerated with createLocalAttestationProof for the same inputs (Yr9EKHjeAFfsFMsF8Xsd7J6LxBYnObweKZlLyTMk0Lo).

@devin-ai-integration

Copy link
Copy Markdown

Fixed in 614ce62 — the verifier now uses identity.attestation_secret.as_bytes() as the HMAC key, matching the server's createHmac("sha256", secret) over the encoded secret text, and the unit test vector was regenerated from createLocalAttestationProof.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant