[MEDIUM] Prevent code injection in inheritable_attr - #28
Open
OskarEichler wants to merge 1 commit into
Open
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
instance_evalininheritable_attrwithdefine_singleton_methodclosures.clone: falsebehavior.Severity: medium. If an application derives an inheritable attribute name from untrusted input, the current interpolation allows that string to escape the generated method and execute arbitrary Ruby in the application process. Exploitation requires a consumer to pass attacker-controlled data into this class-level DSL; static application declarations are not exposed.
Reproduction
Against 0.1.0 and current
master:The generated source accepts
__END__, so the payload closes the first method, runs arbitrary Ruby, and hides the remainder of the template. On this branch the invalid instance-variable name raisesNameErrorbefore defining accessors and$uber_injectedremainsfalse.Verification
clone: false, and a Unicode identifier.git diff --checkpasses.Compatibility and limits
NameError. Valid accessor APIs and inheritance behavior are preserved.define_singleton_methodblock as their source location instead of the former eval line.