Repository navigation
Conversation
Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 10 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch has not been deployed
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.
Hi there, here is a proposed fix for this issue.
Fixes #103
Thanks for the issue, the sample line and the list of what to flag were easy to turn into tests. This adds SG-018, "Library Preloaded Into Other Programs" (MEDIUM), taking the next free ID since SG-016 and SG-017 are still open in #210 and #211.
src/skillshield/rules.py: the rule and its entry inALL_RULES. It flagsLD_PRELOADorDYLD_INSERT_LIBRARIESset to a value (export,env, a leadingVAR=value command, DockerfileENV, cshsetenv),LD_LIBRARY_PATHwith/tmp,/var/tmp,/dev/shmor aDownloadsfolder among its entries, and writes to/etc/ld.so.preload(a redirect,tee,cp,mv,install, or Pythonopenfor writing). Tags areowasp-asi05andowasp-ast01. The description tells the reviewer that some legitimate skills do this and to check why, as the issue asks.tests/test_sg018_library_preload.py: the sample from the issue, 23 differently worded true positives, 17 near misses (text that only explainsLD_PRELOAD,unset,echo $LD_PRELOAD, an empty value,/tmpfiles,catandgrepon/etc/ld.so.preload, and others), a check of the tags, and timing checks on long unbroken inputs. Two early patterns were quadratic on long repeated input (cp xrepeated, andLD_LIBRARY_PATH=repeated); the first was caught by a timing check and the second by the reviewer, and both are linear now, with a timing case for each.README.md(rules table, OWASP table, rule counts) andCHANGELOG.md.How I checked: the 52 new tests pass, and with the rule taken out of
ALL_RULES33 of the first 49 (checked before the last three were added) fail (the rest are the near misses, which pass either way).ruff check src testsandblack --check src testsare clean. On the full suite, 1780 passed and 14 failed: the twotests/test_redteam.pytests that need.pycfiles (they fail on a fresh checkout of main too, since the partial clone leaves binary files out) and 12 timing tests on other rules (test_*_stays_fast*,test_hostile_*_scans_fast, and the English-text skip tests for French and German). The Mac was under heavy load while they ran (load average above 20); I reran those 12 on main under the same load and 7 failed there as well, and the 6 that still failed on my branch are among them, so I read them as load, not this change. I did not get a quiet-machine rerun. I ran Python 3.12 only, not the rest of the matrix.Not covered, since the issue did not list them: setting the variable from code (
os.environ["LD_PRELOAD"] = ...), JSON or YAML env blocks ("LD_PRELOAD": "..."),dd of=,ln -sandsed -iaimed at/etc/ld.so.preload,DYLD_LIBRARY_PATH, and a preload set inside a script variable. Prose that quotes a fullexport LD_PRELOAD=/pathline is flagged too, like the other pattern rules.