Skip to content

Harden security defaults: unsafe tools off, CORS lockdown, error sanitization#22

Merged
jaden688 merged 3 commits intomainfrom
copilot/fix-security-issues
Mar 28, 2026
Merged

Harden security defaults: unsafe tools off, CORS lockdown, error sanitization#22
jaden688 merged 3 commits intomainfrom
copilot/fix-security-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

Several security posture issues: shell/bridge tools enabled by default, CORS origin reflection in the MCP proxy, exception details leaked to clients, and wildcard CORS methods/headers in the core API.

Unsafe tools default to OFF

  • JL_LOCAL_UNSAFE_TOOLS default changed from "1""0" in builtin.py, quest_runtime.py, .env.example
  • MCP server (JL-Engine-local.py) still explicitly sets "1" — no behavior change for that entrypoint
# before
raw = str(os.getenv("JL_LOCAL_UNSAFE_TOOLS", "1")).strip().lower()

# after
raw = str(os.getenv("JL_LOCAL_UNSAFE_TOOLS", "0")).strip().lower()

CORS origin reflection → allowlist

  • mcp_https_proxy.py reflected any client Origin header verbatim and fell back to *
  • Now validates against a static set of localhost origins

Proxy error response sanitization

  • Raw str(exc) was interpolated into client-facing JSON
  • Now returns generic "An internal proxy error occurred." and logs the real error server-side

Tighten CORS in core API

  • api_app.py: allow_methods=["*"] / allow_headers=["*"] → explicit lists of methods and headers actually used

SECURITY.md

  • Documents default-off unsafe tools, CORS policy, error handling stance

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented Mar 27, 2026

DeepSource Code Review

We reviewed changes in 40a8144...c6b2a10 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Java Mar 27, 2026 11:35a.m. Review ↗
Shell Mar 27, 2026 11:35a.m. Review ↗
Python Mar 27, 2026 11:35a.m. Review ↗
Secrets Mar 27, 2026 11:35a.m. Review ↗

@jaden688 jaden688 marked this pull request as ready for review March 27, 2026 11:25
Copilot AI and others added 2 commits March 27, 2026 11:33
- Change JL_LOCAL_UNSAFE_TOOLS default from "1" to "0" (opt-in, not opt-out)
- Update .env.example to match safe default
- Fix CORS origin reflection in mcp_https_proxy.py (use allowlist)
- Sanitize proxy error responses to not leak exception details
- Tighten CORS methods/headers in api_app.py (explicit lists)
- Update quest_runtime.py to respect env-based unsafe tools default
- Update SECURITY.md to document changes

Agent-Logs-Url: https://github.com/jaden688/JL_Engine-local/sessions/516698b7-cb1d-4c2d-b679-da97deb72ffe

Co-authored-by: jaden688 <173667368+jaden688@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix security issues identified in the project Harden security defaults: unsafe tools off, CORS lockdown, error sanitization Mar 27, 2026
Copilot AI requested a review from jaden688 March 27, 2026 11:36
@jaden688 jaden688 merged commit 5bd4793 into main Mar 28, 2026
16 of 18 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in @jaden688's JL-Engine Mar 28, 2026
@jaden688 jaden688 deleted the copilot/fix-security-issues branch April 20, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants