Skip to content

Do not eval OpenVPN foreign options as shell - #641

Open
SebTardif wants to merge 1 commit into
ivpn:developmentfrom
SebTardif:bugfix/openvpn-up-foreign-option
Open

SebTardif wants to merge 1 commit into
ivpn:developmentfrom
SebTardif:bugfix/openvpn-up-foreign-option

Conversation

@SebTardif

Copy link
Copy Markdown

PR type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other... Please describe:

PR checklist

  • I have read the CONTRIBUTING.md doc
  • The Git workflow follows our guidelines: CONTRIBUTING.md#git
  • I have added necessary documentation (if appropriate)

What is the current behavior?

On Linux, OpenVPN runs client.up as root (script-security 2). The script reads each foreign_option_N value, which comes from the server PUSH, with eval. That re-parses the value as shell. The case test was also unquoted.

Issue number: N/A

What is the new behavior?

The value is read with printf '%s' inside quotes, and the case word is quoted. DNS and domain parsing stays the same. A PUSH value is not executed as shell.

TestClientUpDoesNotEvalForeignOption checks the script text and that a value containing $(...) stays literal.

Does this PR introduce a breaking change?

  • Yes
  • No

Normal dhcp-option DNS and dhcp-option DOMAIN pushes still update DNS.

Other information

Base is development. This is Linux only. The macOS DNS script reads these values from the environment without eval.

client.up used eval on foreign_option_N, which re-parses the server
PUSH. Read the value with a quoted printf and match it as a quoted
string so command substitution in the push is not executed.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
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.

1 participant