Sanitize IDL text written into generated comments and strings - #240
Merged
Merged
Conversation
Values from the IDL were copied verbatim into generated source files. A crafted IDL could close the surrounding comment or string literal and inject code into the generated bindings and implementation stubs. - Sanitize the copyright and license lines for each license header comment style (C-style, Pascal, Python, CMake), including C/C++ backslash line splicing and Java unicode escapes, and warn when a value is changed. - Reject method, class, function type, parameter, error, enum and enum option descriptions that could terminate the comment they are written into. Parameter descriptions are now validated; the method check previously validated the method description instead. - Escape function type descriptions written into Python string literals and sanitize descriptions written into Javadoc comments. - Add unit tests for the sanitizer and the description validation.
martinweismann
force-pushed
the
fix/generated-comment-injection
branch
from
September 29, 2026 19:30
12c06ea to
bcc6fda
Compare
Emscripten 4.0.22 and later require Python 3.10, but the CentOS 8 image only provides Python 3.9, so installing the latest emsdk fails. Co-authored-by: Cursor <cursoragent@cursor.com>
gangatp
self-requested a review
September 30, 2026 07:25
gangatp
approved these changes
Sep 30, 2026
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.
Summary
ACT copied several IDL values verbatim into generated source files. A crafted IDL could close the surrounding comment or string literal and inject code into the generated bindings and implementation stubs. This is a potential code injection vulnerability for anyone who generates code from an IDL they don't fully control.
Changes
License headers: the
copyrightattribute and the<license>lines are now sanitized for each header comment style before they are written:/* */, used for C, C++, C#, Go, Node, Java and JavaScript):*/and/*are broken up.\u002a/are neutralized.??/trigraph is neutralized, so C/C++ line splicing can't assemble*/across lines.(* *)):*)and(*are broken up.'''): backslashes and single quotes are escaped.#[[ ]]):]]is broken up.ACT logs a warning once per affected value. Existing IDLs keep working, and headers whose text needs no sanitizing are byte-for-byte unchanged.
Descriptions: method, class, function type, parameter, error, enum and enum option descriptions that could terminate the comment they are written into are now rejected. This covers
*/,/*,*),(*, Java unicode escapes, trailing backslashes and control characters.*and/, so these sequences were previously accepted.Escaping at write time: function type descriptions are escaped before being written into a Python string literal, and descriptions written into Javadoc comments are sanitized.
Tests: new unit tests in
Source/languagewriter_test.goandSource/componentdefinition_test.go.Example build image:
Build/Dockerfilenow pins emsdk to 4.0.21 instead oflatest. The example build failed independently of this change: Emscripten 4.0.22 and later require Python 3.10, and the CentOS 8 image only provides Python 3.9.Testing
GO111MODULE=off go test -vet=off .inSourcepasses.-vet=offis needed becausego vetalready fails on existingint-to-stringconversions incomponentdiff.go.\u002a/.-Wall -Werror, and the Python bindings contain no injected code. The description payloads are rejected with a validation error.