Skip to content

debug(policy): add SHA-256 trace logs at sign / use / attach#41

Merged
sashyo merged 1 commit into
mainfrom
debug/policy-trace-logs
May 20, 2026
Merged

debug(policy): add SHA-256 trace logs at sign / use / attach#41
sashyo merged 1 commit into
mainfrom
debug/policy-trace-logs

Conversation

@sashyo
Copy link
Copy Markdown
Owner

@sashyo sashyo commented May 20, 2026

Summary

Adds three matching trace log lines so we can compare the policy bytes byte-for-byte across the sign → store → use → attach hops, to pin down where (if anywhere) the bytes are diverging when Sign #2 still fails with "Policy signature could not be verified".

Tag Where What it logs
[PolicyTrace SIGN] server/routes.ts (commit endpoint) DataToVerify / signature / composed-policy lengths and SHA-256s when the ssh_policies row is written
[PolicyTrace USE] server/routes.ts (getForSshUser endpoint) Section-0 and section-1 hashes of the bytes the server ships back to the client
[PolicyTrace ATTACH] client/src/lib/tideSsh.ts (just before addPolicy()) Hashes of the policy as the client parses it, immediately before it goes into the BasicCustomRequest

How to read the logs

  • If dtv_sha is identical at SIGN, USE, and ATTACH → bytes are intact end-to-end. The failure lives downstream (heimdall iframe, BasicCustomRequest re-encoding, or ORK side).
  • If any of the three dtv_sha values differs from SIGN, the corruption is at that hop.

Test plan

  • Deploy keylessh server + frontend
  • Commit a fresh SSH policy via Admin Approvals — confirm [PolicyTrace SIGN] line in server log
  • Open SSH connect for the same user — confirm [PolicyTrace USE] line in server log AND [PolicyTrace ATTACH] line in browser console
  • Compare the three dtv_sha values — should be byte-identical

Pure-logging change, no behavior impact.

To diagnose remaining "Policy signature could not be verified" failures,
emit matching trace lines so the operator can compare byte-for-byte:

- [PolicyTrace SIGN]   server/routes.ts at commit — DataToVerify, signature,
  and composed-policy hashes when the row is written.
- [PolicyTrace USE]    server/routes.ts at getForSshUser — section-0 and
  section-1 hashes of what the server ships to the client.
- [PolicyTrace ATTACH] client/src/lib/tideSsh.ts before addPolicy() — hashes
  of the policy as parsed by the client just before it goes into the
  BasicCustomRequest.

If dtv_sha is identical at SIGN, USE, and ATTACH, the bytes are intact
end-to-end and the verify failure lives downstream (heimdall iframe /
ORK side). If any of the three differ, that hop is the corruption point.
@sashyo sashyo merged commit d8a239d into main May 20, 2026
2 checks passed
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.

1 participant