Skip to content

F 739 : fix shell command injection#213

Open
miyazakh wants to merge 3 commits intowolfSSL:mainfrom
miyazakh:f-739_shellcommand
Open

F 739 : fix shell command injection#213
miyazakh wants to merge 3 commits intowolfSSL:mainfrom
miyazakh:f-739_shellcommand

Conversation

@miyazakh
Copy link
Copy Markdown
Contributor

@miyazakh miyazakh commented Mar 27, 2026

F-739 : Shell command injection via popen with unsensitized hostname
Add test coverage

Depend on : #211 (Fixed)
Depend on : #219

Copilot AI review requested due to automatic review settings March 27, 2026 00:06
@miyazakh miyazakh self-assigned this Mar 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a shell command injection risk in the client hostname resolution path (when using popen("host ...")) and expands regression coverage to detect attempted command execution via crafted -connect hostnames.

Changes:

  • Add hostname character validation before constructing a popen() command in the client.
  • Add client regression tests that ensure injected shell metacharacters do not result in file creation.
  • Loosen OCSP interop test error-message matching and adjust hash-type switch guards for newer wolfSSL versions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/client/client.c Adds hostname validation to prevent shell metacharacters from reaching the popen() command.
tests/client/client-test.sh Adds regression tests intended to detect hostname-based shell injection.
tests/ocsp/ocsp-interop-test.sh Expands grep patterns for expected failure messages in interop testing.
src/x509/clu_x509_sign.c Updates preprocessor version gating for additional WC_HASH_TYPE_* enum cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@miyazakh miyazakh force-pushed the f-739_shellcommand branch from 566a39f to b55a628 Compare April 7, 2026 21:11
@miyazakh miyazakh marked this pull request as ready for review April 7, 2026 21:11
Copilot AI review requested due to automatic review settings April 7, 2026 21:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@miyazakh miyazakh force-pushed the f-739_shellcommand branch from b55a628 to 144f4bb Compare April 9, 2026 00:37
@miyazakh miyazakh assigned wolfSSL-Bot and unassigned miyazakh Apr 9, 2026
Copy link
Copy Markdown
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

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

🐺 Skoll Code Review

Overall recommendation: APPROVE
Findings: 2 total — 2 posted, 0 skipped

Posted findings

  • [Low] #include <ctype.h> placed between wolfSSL headerssrc/client/client.c:37
  • [Medium] Missing backtick command-substitution injection test casetests/client/client-test.sh:28-60

Review generated by Skoll via openclaw

#endif
#include <wolfssl/wolfcrypt/settings.h>

#include <ctype.h>
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.

🔵 [Low] #include <ctype.h> placed between wolfSSL headers
🔧 NIT convention

The new #include <ctype.h> is placed on line 37 between wolfssl/wolfcrypt/settings.h (line 35) and wolfssl/ssl.h (line 39). In wolfSSL convention, settings.h is typically followed immediately by other wolfSSL headers since it sets up preprocessor macros those headers depend on. System includes are conventionally grouped together. The include is needed (for the pre-existing isalpha() call on line 142), so adding it explicitly is correct — only the placement is slightly off.

Suggestion:

Suggested change
#include <ctype.h>
Move `#include <ctype.h>` to after `#include <wolfssl/ssl.h>` or group it with the other system includes near the top of the file (around the `#include <config.h>` block).


rm tmp.crt

# Regression tests: shell injection via hostname must not execute injected command.
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.

🟡 [Medium] Missing backtick command-substitution injection test case
💡 SUGGEST test

The regression tests cover three shell injection vectors: semicolons (;), dollar-paren command substitution ($()), and pipes (|). However, backtick command substitution (`cmd`) is a fourth classic shell injection vector that is not tested. While the allowlist validation in client.c blocks backticks (they are not in [A-Za-z0-9.-]), adding a test for completeness would strengthen the regression suite and document the intent. An & (background execution) test would also be a nice-to-have.

Suggestion:

Suggested change
# Regression tests: shell injection via hostname must not execute injected command.
# Backtick command substitution: "`touch clu_injection_probe.txt`" passed as peer
./wolfssl s_client -connect 'evil`touch clu_injection_probe.txt`.com:443' \
2>/dev/null
if [ -f "$INJFILE" ]; then
echo "SECURITY FAILURE: command injection via hostname (backtick)"
rm -f "$INJFILE"
exit 99
fi

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