Skip to content

Escape problematic characters in CREDITS files #8767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Jun 13, 2022

On Windows, the contents of the CREDITS files are passed to rc.exe via
the command line. To avoid undesired behavior, we need to escape some
characters, most notably < (which is sometimes used in CREDITS to
enclose mail addresses), which otherwise is interpreted as redirection
operator, resulting in the hard to understand "The system cannot find
the file specified."

Even more dangerous is not properly escaping percent signs, which makes
it possible for a malicious CREDITS file to inject the values of
environment variables of the build system into the generated binaries.
This is particularly bad, because as of Windows Vista, the comments can
no longer be inspected via explorer.exe, although the binaries still
contain these comments.

We also cater to double-quotes, which need to be escaped as \"\" in
this context.


If we don't want to allow these characters in CREDITS, it would still make sense to explicitly error out, telling developers to remove these characters.

Note that I haven't been able to figure out how to properly deal with non ASCII UTF-8 characters (I assume that most CREDITS files are UTF-8 encoded nowadays). That appears to be a minor issue, though, since the comments are not visible via explorer.exe anyway.

cc @asgrim

On Windows, the contents of the CREDITS files are passed to rc.exe via
the command line.  To avoid undesired behavior, we need to escape some
characters, most notably `<` (which is sometimes used in CREDITS to
enclose mail addresses), which otherwise is interpreted as redirection
operator, resulting in the hard to understand "The system cannot find
the file specified."

Even more dangerous is not properly escaping percent signs, which makes
it possible for a malicious CREDITS file to inject the values of
environment variables of the build system into the generated binaries.
This is particularly bad, because as of Windows Vista, the comments can
no longer be inspected via explorer.exe, although the binaries still
contain these comments.

We also cater to double-quotes, which need to be escaped as `\"\"` in
this context.
asgrim added a commit to scoutapp/scout-apm-php-ext that referenced this pull request Jun 15, 2022
@cmb69
Copy link
Member Author

cmb69 commented Jun 18, 2022

If there are no objections, I'll merge this on Monday, so it'll get into PHP 8.2.0alpha2.

@cmb69 cmb69 closed this in 8aa7e20 Jun 20, 2022
@cmb69 cmb69 deleted the cmb/escape-credits branch June 20, 2022 14:03
asgrim added a commit to scoutapp/scout-apm-php-ext that referenced this pull request Jun 22, 2022
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