fix(ssl): prevent shell injection via site name in self-signed cert generation#495
Open
mrrobot47 wants to merge 1 commit into
Open
fix(ssl): prevent shell injection via site name in self-signed cert generation#495mrrobot47 wants to merge 1 commit into
mrrobot47 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (security — command injection / root RCE)
Site_Self_Signed.phpbuildsopensslcommands withsprintfand runs them viaEE::exec→proc_open→/bin/sh -c. The site name (and the file paths derived from it) were interpolated into those command strings withoutescapeshellarg, and the site name is not charset-validated anywhere upstream (name_checks_and_updatesonly lowercases / appends.test; ee-core has no validation either). So a name likex$(touch /tmp/PWNED).compassed toee site create … --ssl=selfwould execute an attacker subshell as the EasyEngine (root) user. Confirmed reachable end-to-end.Fix
Wrap every user- and config-derived value interpolated into the
opensslshell commands withescapeshellarg()— the site-name-derived CSR/key/cert/conf paths, the CA key/pem/serial paths, and the CA password.escapeshellargonly changes shell parsing, soopensslstill receives the literal-subj/SAN/pass:/path values — no functional change, but shell metacharacters can no longer break out. The class no longer trusts its input (defense-in-depth), independent of any upstream validation.$serial_stringis already escaped where it is built, so it is interpolated as-is at the final call to avoid double-quoting-CAserial.Out of scope
The CA password is still passed as a
pass:argument and logged in cleartext (the$obfuscateargument toEE::execis unused) — tracked separately as audit finding A-04.Testing
Manual:
ee site create 'x$(touch /tmp/INJECT).com' --ssl=self(or with backticks) must NOT create/tmp/INJECTand must treat the metacharacters as literal; a normal--ssl=selfsite still generates its self-signed cert correctly.