Skip to content

agent: exchange whole messages when signing - #1308

Open
ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:agent-signreq
Open

ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:agent-signreq

Conversation

@ejohnstown

@ejohnstown ejohnstown commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • A short write, a hang-up, or a failed setup is WS_AGENT_CXN_FAIL, and cleanup runs only after a successful setup.
  • The ECDSA user-auth path reserves the SSH blob's room, checks the agent's algorithm name, and is covered for each curve.

Fixes F-13325, F-14629, F-14631.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 22:28

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 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.

Comment thread wolfssh/agent.h Outdated
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

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-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.

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

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.

3 participants