Skip to content

Fix(chore): security hardening#55

Merged
karim-semmoud merged 13 commits into
mainfrom
fix/security-hardening
Jun 2, 2026
Merged

Fix(chore): security hardening#55
karim-semmoud merged 13 commits into
mainfrom
fix/security-hardening

Conversation

@karim-semmoud
Copy link
Copy Markdown
Member

Summary

Addresses findings from the Corex security audit across client hooks, Mix generators, the installer, components, MCP configuration, and release hygiene. Each area is a separate commit for review.

This PR is independent of #54 (fix/mcp-security-hardening), which hardens the MCP transport itself (Tidewave alignment, relative paths, prod guard, tool validation). This branch adds configurable MCP error redaction and remote-access warnings on top of the existing plug behavior.

Motivation

A full-library review identified trust-boundary gaps: DOM events treated like server payloads, generator path traversal, EEx re-evaluation on inject, installer string injection, CSS breakout in inline styles, open redirect patterns in links/pagination, and verbose MCP errors leaking stack traces to clients.

Commits

Commit Theme
fix(toast): ignore labelHtml and execJs from untrusted DOM events Split trusted server vs untrusted DOM toast action parsing
fix(mix): contain corex.code output paths within project root assert_within_project_root!/1 for generated file paths
fix(mix): validate generator flags and migration_dir validate_identifier!/1, validate_migration_dir!/1, schema validation
fix(mix): stop EEx re-eval in inject_eex_before_final_end Plain string splice instead of EEx.eval_string on target files
fix(installer): harden --dev path and COREX_NEW_CACHE_DIR copy Quote/validate dev path; File.cp_r!/2 per entry for cache copy
fix(installer): validate web_module like root module Same validity/availability checks as root module in corex.new
fix(color-picker): reject CSS breakout in inline style values Strict color parse only; no passthrough into --value / presets
fix(components): harden file upload cancel, navigate, and pagination URLs Corex.Url.allowed_href?/1 (via URI.parse/1); safe cancel helper
chore: re-enable sobelow checks and add hex.audit to release.check Drop global RCE.EEx / Traversal.FileModule ignores; scoped file ignores
dev(mix): add sponsor link Unrelated housekeeping (consider dropping from this PR if you want a pure security diff)
fix(mcp): redact tool errors by default and warn on remote access mcp_verbose_errors, gated debug logging, init warning for remote access

Changes by area

Toast (F1)

Mix generators and corex.code (F3, F4, F7)

Installer (F2, F5, F6, F16)

Color picker (F8)

Components (F12, F13)

MCP (F9, F10, F11)

Hygiene (F15)

  • .sobelow-conf: re-enable Traversal.FileModule and RCE.EEx globally; ignore_files only for generator/doc tooling paths
  • mix.exs: release.check runs hex.audit before lint

Relationship to PR #54

Concern This PR PR #54
MCP transport / Tidewave alignment No Yes
Relative source_path, prod guard, tool arg validation No Yes
CSP rewrite removal on non-MCP routes No Yes
Tool error redaction (mcp_verbose_errors) Yes No (deferred there)
Remote access init warning Yes No

Recommended merge order: land #54 first, then rebase this branch and resolve any overlap in lib/mcp/plug.ex, lib/mcp/server.ex, and guides/MCP.md.

Test plan

  • mix test
  • mix lint
  • mix release.check (includes hex.audit)
  • cd e2e && mix test (POST/PUT controller and form tests; MCP e2e)
  • cd integration_test && mix test --include database
  • npm test in assets/ (toast hook tests)
  • Manual: toast DOM events cannot inject HTML/JS actions; navigate rejects javascript: URLs
  • Manual: MCP tool failure returns generic message unless mcp_verbose_errors: true

Breaking changes

None for normal app usage. Generator operators passing invalid --migration-dir or schema names now get explicit errors instead of silent bad output.

@karim-semmoud karim-semmoud self-assigned this Jun 2, 2026
@karim-semmoud karim-semmoud merged commit 59b0eb2 into main Jun 2, 2026
14 checks passed
@karim-semmoud karim-semmoud deleted the fix/security-hardening branch June 2, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant