[MEDIUM] Reject executable lines in generated annotations - #391
Open
OskarEichler wants to merge 1 commit into
Open
[MEDIUM] Reject executable lines in generated annotations#391OskarEichler wants to merge 1 commit into
OskarEichler 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.
Summary
Security impact
MEDIUM urgency. Several annotation components interpolate database schema metadata such as constraint expressions, names, index details, and enum values. If one of those values contains a newline, the following text can escape the leading
#and be written as executable Ruby into a model or related source file. A later application boot or test run can execute that generated line.Exploitation requires control of relevant database schema metadata (or direct control of the low-level annotation string) plus a developer or CI run of AnnotateRb. The gem is normally a development tool, which limits exposure, but the resulting impact is source-code execution in that environment.
Reproduction
A check-constraint component with an expression ending in a newline plus
raise 'generated-code-marker'currently generates:Passing that annotation to
SingleFileAnnotatorwrites the uncommented line into the model. With this patch, the call raisesArgumentErrorbefore changing the file.Verification
libRuby files compile.git diff --check.Limitations
This validates model and related-file annotations at their final write boundary. Route annotation generation uses a separate path and prefixes every route-map row itself; configuration files and the project Rakefile remain trusted local code.
Breaking changes
Callers that intentionally pass non-comment content through the low-level model annotation API now receive
ArgumentError. Generated annotation blocks are documented and expected to contain comments only.