Repository navigation
fix(fri): validate build/clear query args before they reach cmd.exe - #725
Open
SahilKumar965 wants to merge 1 commit into
Open
SahilKumar965 wants to merge 1 commit into
SahilKumar965 wants to merge 1 commit into
Conversation
On Windows, /build and /clear pass maxtime, params, fetch, outdir and apikey into call(..., shell=True). list2cmdline does not escape & | > ^, so maxtime=100&calc runs calc. Validate these args and return 400.
|
🎉 Welcome aboard, @SahilKumar965! Thank you for your first pull request in concore. Please ensure that you are contributing to the dev branch. Your contribution means a lot to us. We'll review it shortly. Please ensure you have reviewed our: If you have any questions, feel free to ask. Happy coding! |
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.
On Windows,
/buildand/clearinfri/server/main.pypass query parameters intocall(..., shell=True). Python'slist2cmdlinedoesn't escape& | > ^, soPOST /clear/x?maxtime=100%26calcreaches cmd.exe asmaxtime 100&calcand runscalc.Change
validate_run_args():maxtimemust be a number; on Windows,paramscan't contain& | < > ^ % ! "or newlines. Normal params likea=1;b=[1,2]still work./buildnow validatesfetch,outdir,apikey,maxtime,params(apikeyalso goes into themakestudycommand)./clearvalidatesmaxtimeandparams./library.Tests
tests/test_fri_input_validation.pymakes the server think it's on Windows and records shell calls instead of running them. 9 of the new tests fail without the fix and all pass with it. The full suite passes and ruff is clean.Notes
requirements-ci.txt, so CI skips the FRI tests (this one andtest_openjupyter_security.py). I ran them locally with Flask installed. Should I add Flask to CI?outdircan still contain../, and the build/run endpoints still have norequire_api_key(), since that would need concore-editor to send the key.paramsvalues can't use"; single quotes still work.AI use: I used Claude (AI assistant) while working on this; I reviewed the changes and ran all tests myself.