bug: fix OS command injection in POST /create identify call - #216
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
bug: fix OS command injection in POST /create identify call#216devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] 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
exports.createfed an attacker-controlled markdown image URL straight intoexec('identify ' + url), i.e./bin/sh -c, on an unauthenticated route — any;,|, backtick or$(...)in the captured URL ran as a shell command.exec→execFile('identify', [url], cb): no shell, url is a single argv entry.isInspectableImageUrl(url)gate before the sink: <=2048 chars,^[A-Za-z0-9._~:/?#@%+=-]+$(excludes whitespace and every shell metacharacter), andvalidator.isURL(url, {protocols:['http','https'], require_protocol:true}). Rejected URLs are logged and skipped; the todo is still saved.(http.*)→(http[^)\s]*)so the group can't swallow trailing markdown/payload text.Auth was intentionally left unchanged — creating todos is the app's anonymous core flow; the fix removes the shell rather than the endpoint.
Testing
tests/create-command-injection.spec.jsstubschild_processand the mongoose models, callsroutes.createdirectly, and asserts no child process spawns for shell payloads (;,&&, backticks, newline,file://) while a benignhttp://example.com/snyk.pngstill yieldsexecFile('identify', ['http://example.com/snyk.png']). 18/18 assertions pass.Devin-Org: engineering
Devin Review