Skip to content

Wipe channel strings that can carry secrets - #1358

Open
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:channel-strings
Open

ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:channel-strings

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

Two channel strings that can hold credentials are zeroed before they
are released.

  • DoChannelRequest() wipes the env request value on every exit
  • FreeChannelName() wipes and frees the client exec command line;
    unit test reads back each freed name

Issue: F-8849, F-14691

The env branch decodes the peer's variable value into a stack buffer
that can carry a token. Zero it before it leaves scope, on success and
on a parse error alike.

Issue: F-8849
The client keeps its exec command line, which can carry credentials,
in ssh->channelName. FreeChannelName() wipes and frees it, mirroring
FreeChannelCommand() on the server side.

- use it in SshResourceFree() and at the three wolfSSH_SetChannelType()
  release sites
- unit test reads back each freed name through a retaining allocator

Issue: F-14691
Copilot AI balanced review requested due to automatic review settings November 2, 2026 18:56

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

No active review issues remain for the changes intended to reduce credential remnants in memory.

No open issues 🎉

What changed in this PR

This PR reduces credential remnants in memory by wiping channel strings before release in wolfSSH’s request handling and client session cleanup.

Changes:

  • Wipes the temporary environment-request value before leaving its handling block.
  • Centralizes wiping and freeing stored exec/subsystem names in FreeChannelName().
  • Adds unit coverage that checks released exec-name buffers after channel-type changes, command replacement, and session cleanup.
File Description
wolfssh/​internal.h Declares the shared FreeChannelName() helper.
tests/​unit.c Adds and registers exec-name wiping tests.
src/​ssh.c Uses the cleanup helper when replacing or dropping channel names.
src/​internal.c Implements channel-name wiping, integrates session cleanup, and wipes environment-request values.

Review effort: Balanced

@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 #1358

Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 3 of 4 in-scope changed file(s) opened by the reviewer; not opened: wolfssh/internal.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.

4 participants