security: fix code/command injection in calculators, WP downloader, and KV store - #591
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
security: fix code/command injection in calculators, WP downloader, and KV store#591devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…nd KV store Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Fixes the critical code-/command-injection findings from a security scan of the repo. Each fix preserves the original intended behavior; only the unsafe evaluation/execution path is replaced.
1.
ai-terminal-assistant/main.py— arbitrary code execution (RCE)The
calccommand raneval(value)on raw user input, so e.g.calc __import__("os").system("...")executed arbitrary code. Replaced with anast-basedsafe_eval()that only allows numeric literals and arithmetic operators (+ - * / // % **, unary +/-); anything else raisesValueError.2.
gui-calculator/Calculator.py— arbitrary code executionequate()raneval(display.get()). Replaced with the samesafe_eval()and wrapped in a try/except that showsErrorinstead of crashing on bad input.3.
wordpress_plugin_downloader/downloader.py— OS command injectionlink/filenamecame from scraped page HTML and were interpolated into a shell string. Now passed as argument lists with no shell, so metacharacters can't inject commands.4.
KeyValueStore/db.sh— arbitrary command execution + regex injectionThe script ended in
$@, which executed any function or command name passed as the first argument (e.g.db.sh 'x; touch INJECTED'). It also used unquotedgrep -e $1/sed "s/$1.../", allowing regex/argument injection. Rewritten to:caseallow-list (create|read|update|delete) instead of$@.awk '$1 == key'(passing the key via-v) instead ofgrep/sedregexes.Notes / not fixed
BasicCalculator/script.jsuses client-sideeval()on the user's own input (self-contained, no server/other-user exposure) — flagged as low risk, left as-is.YOUR_API_KEY,<your consumer secret>) or env-var lookups. The only real token is in a committed third-partynode_modulesfile (todolist/node_modules/debug/.coveralls.yml).node_modules(Make-Text-Uppercase, todolist) are outdated and a supply-chain concern, but out of scope for this focused fix.Verification
python3 -m py_compilepasses for all changed Python files.safe_eval("2+3*4")→14; injection payload raisesValueError.db.shcreate/read/update/delete round-trips correctly; injection payload is rejected with a usage error.Link to Devin session: https://app.devin.ai/sessions/53e420bb2b644c55bffeeb860fd69155
Requested by: @josharsh