POSIX wordexp(3) is dangerous
Web page · https://yossarian.net/til/post/posix-wordexp-3-is-dangerous
First seen by Oriel on .
AI summary
This post warns that POSIX wordexp(3), commonly used for tilde expansion, can execute commands by default and may remain unsafe with WRDE_NOCMD.
- wordexp(3) enables shell-style command expansion unless callers pass the WRDE_NOCMD flag.
- Inputs such as "$(whoami)/foo" or "$(cat /etc/passwd)/foo" can trigger command execution through the example function.
- musl delegates wordexp(3) to the system shell and its scanning can miss command-substitution patterns accepted by GNU Bash.
- macOS similarly delegates to wordexp-helper1, which reportedly had a command-substitution bypass as recently as 2023.
- The recommended conclusion is to avoid wordexp(3) for untrusted inputs, even when WRDE_NOCMD is enabled.
#posix #c #shell injection #musl
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Points
Score reported by the source.
- Lobsters: 87, latest observation ; +83 over observed period since
Comments
Comment count reported by the source.
- Lobsters: 20, latest observation ; +20 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| Lobsters | tbbiqb | https://yossarian.net/til/post/posix-wordexp-3-is-dangerous/ Read discussion |