Closed
Conversation
ba818e2 to
b1128a1
Compare
43e1d06 to
5ac67a4
Compare
c34499b to
d732f2f
Compare
|
This pull request introduces a vulnerability in FastCov's StaticMap: it resolves constants via Object.const_get on names parsed from untrusted Ruby files, which can trigger autoload and execute attacker-controlled code, enabling RCE in CI/test-impact scenarios. The risky code is in lib/fast_cov/static_map.rb (lines ~151–154) and should avoid loading constants from untrusted input.
Unsafe Reflection via Constant Loading in
|
| Vulnerability | Unsafe Reflection via Constant Loading |
|---|---|
| Description | The StaticMap utility in FastCov resolves constants by calling Object.const_get on names extracted from Ruby source files using the Prism parser. This call triggers Ruby's autoload mechanism, which executes the file associated with the constant. When used to analyze untrusted code in a CI environment (e.g., for test impact analysis on Pull Requests), an attacker can achieve Arbitrary Code Execution (RCE) by providing a malicious file that is registered for autoloading and then referencing its constant in a parsed file. |
fast_cov/lib/fast_cov/static_map.rb
Lines 151 to 154 in 5c83a0c
All finding details can be found in the DryRun Security Dashboard.
Co-authored-by: Codex <codex@openai.com>
590dc40 to
5c83a0c
Compare
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
FastCov::StaticMapas a build-time API for static Ruby dependency mappingbuildand transitive closure output withbuild_transitiveWhy
Static dependency analysis is useful, but it should live outside the runtime coverage hot path.
StaticMapkeeps that behavior available as an explicit build-time API without reintroducingconstant_referencesintoCoverageTracker.Validation
bundle exec rspec --fail-fast spec/lib/fast_cov/static_map_spec.rb spec/lib/fast_cov/static_map/reference_extractor_spec.rbbundle exec rspec --fail-fast