Skip to content
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

[GDScript] Check string literals for Unicode direction control characters. #54883

Merged
merged 1 commit into from
Nov 11, 2021

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Nov 11, 2021

Fixes potential vulnerability, described in Trojan Source: Invisible Vulnerabilities. Since GDScript do not have {...} blocks, the second vulnerability variant probably is irrelevant.

Before:
before

After:
after

Test script:
dircontrol.gd.zip

Bugsquad edit: Mitigates CVE-2021-42574 for GDScript.

@bruvzg bruvzg added this to the 4.0 milestone Nov 11, 2021
@bruvzg bruvzg requested a review from a team as a code owner November 11, 2021 13:55
@mhilbrunner
Copy link
Member

Good idea. Wonder whether it should be a warning instead of an error.

@bruvzg
Copy link
Member Author

bruvzg commented Nov 11, 2021

For the reference, here's an example of legitimate usage of direction control character: https://hosted.weblate.org/translate/godot-engine/godot/ar/?checksum=3818bad5b65a4bef#comments (using "\uXXXX" escape codes is more convenient way than adding raw characters, so this change won't break anything).

@akien-mga
Copy link
Member

Good idea. Wonder whether it should be a warning instead of an error.

Rust seems to have added "deny by default" lints according to https://blog.rust-lang.org/2021/11/01/cve-2021-42574.html
Which would mean for us warnings treated as errors that could be disabled - but I don't think we have support to do that. Either all warnings are treated as errors, or none, IINM.

How would a typical non-exploit string using such Unicode direction control characters look like, both with and without escape codes? E.g. some Arabic with English words I suppose?

@bruvzg
Copy link
Member Author

bruvzg commented Nov 11, 2021

How would a typical non-exploit string using such Unicode direction control characters look like, both with and without escape codes? E.g. some Arabic with English words I suppose?

Here's a string for Weblate I mentioned before, but with escaped chars, control chars are used to keep English node names and punctuation in the correct order when they are inside the Arabic string.

معاملات غير صالحة للمشغل \u200f\u2068%s\u2069، \u2068%s\u2069\u200f و \u2068%s\u2069.

Invalid operands to operator Alpha, Beta and Gamma.


معاملات غير صالحة للمشغل Alpha، Beta و Gamma.
معاملات غير صالحة للمشغل ‏⁨Alpha⁩، ⁨Beta⁩‏ و ⁨Gamma⁩.


The first line is without control chars, the second with.

@akien-mga akien-mga merged commit c0fdbf1 into godotengine:master Nov 11, 2021
@akien-mga
Copy link
Member

Thanks!

@bruvzg bruvzg deleted the dir_control_warning branch November 11, 2021 15:06
@Calinou
Copy link
Member

Calinou commented Nov 11, 2021

but I don't think we have support to do that. Either all warnings are treated as errors, or none, IINM.

We should likely change each warning property from a boolean to an enum (Warning, Error, Ignore), and remove the warnings to errors setting in 4.0. This way, each warning can be configured to emit an error (and we can do this by default for a few warnings).

Edit: Proposal opened: godotengine/godot-proposals#3531

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants