Repository navigation
agent: exchange whole messages when signing - #1308
ejohnstown wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The public signing API can dereference a null signature buffer instead of returning its documented argument error.
1 open finding
What changed in this PR
Updates agent signing to exchange complete messages and safely handle fragmented I/O.
Changes:
- Loops over short writes and fragmented replies.
- Improves setup/cleanup handling.
- Correctly sizes and validates ECDSA agent signatures with expanded tests.
| File | Description |
|---|---|
wolfssh/agent.h |
Documents the signing API contract. |
src/agent.c |
Implements complete request/reply exchanges. |
src/internal.c |
Fixes ECDSA signature sizing and algorithm validation. |
tests/api.c |
Tests fragmented I/O and setup failures. |
tests/regress.c |
Adds end-to-end agent authentication coverage. |
examples/client/client.c |
Prevents invalid or duplicate descriptor cleanup. |
apps/wolfssh/wolfssh.c |
Applies equivalent descriptor lifecycle handling. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wolfSSH_AGENT_SignRequest() writes the sign request and reads the reply through the whole-message helpers the relay uses, so a short write is followed up and a reply is read to its declared length before it is parsed. The setup callback's WS_AgentCbError result becomes WS_AGENT_CXN_FAIL, and an ECDSA key's reply room fits the SSH blob. - A short write, a hang-up, or a failed setup is WS_AGENT_CXN_FAIL; cleanup runs only after a setup that succeeded, and the client callbacks close their socket when connect() fails. - PrepareUserAuthRequestEcc() reserves r and s as mpints a pad byte over the curve size, and BuildUserAuthRequestEcc() hands the agent that room, checks the reply's algorithm name, and bounds it by outputSz. - A NULL sig, or a NULL digest or key blob with a size, is WS_BAD_ARGUMENT; agent.h documents the contract and return codes. - api: the mock agent's short write is followed up, a reply read a byte at a time is reassembled, and a failed setup and NULL buffers are refused. - regress: the mock agents answer as a stream; ECDSA user auth for each curve at, under, and over the largest blob, and a wrong curve name refused; a failed setup refused with nothing sent. Issue: F-13325, F-14629, F-14631
c577631 to
bae0cd3
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1308
Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 4 of 7 in-scope changed file(s) opened by the reviewer; not opened: examples/client/client.c, tests/regress.c, wolfssh/agent.h
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite

wolfSSH_AGENT_SignRequest() now writes the request and reads the reply as whole messages, so a short write is followed up and a reply is read to its declared length before it is parsed.
Fixes F-13325, F-14629, F-14631.