fix(security): remediate Snyk Code Python findings (command injection, open redirect, raw JSON) - #35
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…redirect, raw JSON response) Co-Authored-By: shayan <shayan@cognition.ai>
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
Root-cause fixes for Snyk Code (SAST) findings in the Python codebase:
python/CommandInjection—scripts/cypress_run.py: the Cypress command was built as an f-string (spec path, browser from env, group id) and run viasubprocess.Popen(cmd, shell=True). It is now an argv list passed without a shell (xvfb-runand its--server-argsare split explicitly); the dry-run/RUN log output usesshlex.join.python/OpenRedirect—superset/views/core.py(exploreredirect todatasource.default_endpoint) andsuperset/views/users/api.py(/api/v1/me/avatarredirect to Slack avatar URL). Addedis_safe_redirect_target()insuperset/utils/urls.pywhich allows only relative paths or absolutehttp(s)URLs, and rejects protocol-relative (//,\\) and non-web schemes (javascript:,data:…). Both redirect sites now gate on it.python/XSS—superset/views/api.py/api/v1/query/returned a rawjson.dumpsstring, which Flask serves astext/html. Wrapped injson_success()so it is returned asapplication/json.Deliberately skipped (with rationale):
python/OpenRedirectinsuperset/views/redirect.py:73— already validated byis_safe_redirect_url()+DANGEROUS_SCHEMESblock; finding is a false positive.python/XSSinsuperset/security/api.py,superset/async_events/api.py,superset/views/core.py(generate_json/json_error_response),superset/views/auth.py,superset/views/datasource/views.py— these already respond viaself.response()/json_error_response()/json_success()(JSONapplication/json) or Jinjarender_app_template, which autoescapes; no HTML reflection exists.python/PT(path traversal) insuperset/app.py:119,126—send_static_filedelegates to Flask'ssend_from_directory, which already normalizes and confines to the static folder (raisesNotFoundotherwise); the override only changes the 404→204 for hot-update files.python/Jinja2AutoEscapeinscripts/erd/erd.py,RELEASING/generate_email.py,superset/cli/…— these render non-HTML text templates (DOT/Markdown/plain-text email) from repo-controlled inputs; enabling HTML autoescape would corrupt output.python/HardcodedPassword/HardcodedSecret— all reported locations are test fixtures, example configs (superset/config.pyplaceholder defaults) or docs; no real secrets.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
ruff check/ruff format --checkon changed files: pass.python scripts/cypress_run.py --parallelism-id 0 --dry-runprints the expected argv-based command.test_is_safe_redirect_targetintests/unit_tests/utils/urls_tests.py; runpytest tests/unit_tests/utils/urls_tests.py.curl -X POST /api/v1/query/should now returnContent-Type: application/json.ADDITIONAL INFORMATION
Link to Devin session: https://app.devin.ai/sessions/6722f19ed59a48bda02a0275375426c9
Open in Devin Desktop: https://app.devin.ai/desktop/session/6722f19ed59a48bda02a0275375426c9?variant=devin
Requested by: @shayanshafii