Skip to content

fix(security): prevent SQL injection, unbounded recursion, and condition DoS#71

Merged
mostafa merged 1 commit into
mainfrom
fix/security-critical
May 6, 2026
Merged

fix(security): prevent SQL injection, unbounded recursion, and condition DoS#71
mostafa merged 1 commit into
mainfrom
fix/security-critical

Conversation

@mostafa
Copy link
Copy Markdown
Member

@mostafa mostafa commented May 6, 2026

Summary

  • Validate SQL identifiers in the PostgreSQL backend with a regex allowlist, returning InvalidIdentifier errors instead of interpolating untrusted strings into queries
  • Convert deep_merge to an iterative implementation with MAX_DEPTH=64, returning MergeTooDeep on crafted YAML
  • Add length cap (64 KB) and recursion depth counter (64) to the condition parser, returning ConditionTooLong on oversized input

Test plan

  • New unit tests for SQL identifier rejection (field_expr_rejects_quote_in_field_name, resolve_table_rejects_quote_in_schema_name, etc.)
  • New test for legitimate dotted JSON paths still working
  • deep_merge_handles_deeply_nested_global verifies depth limit triggers
  • deep_merge_succeeds_at_reasonable_depth verifies normal operation
  • condition_too_long_returns_error and moderate_condition_still_parses
  • All existing tests pass

…ion DoS

- Add SQL identifier validation to Postgres backend field_expr,
  resolve_table, and qualify_table_name to prevent injection via JSONB
  field paths and table/schema names
- Convert deep_merge from recursive to depth-limited (MAX_DEPTH=64)
  with MergeTooDeep error variant to prevent stack overflow from
  crafted YAML input
- Add 64KB length cap and depth counter (64) to condition parser to
  prevent DoS via oversized or deeply nested condition strings
- Add regression tests for all three vulnerability classes
@mostafa mostafa force-pushed the fix/security-critical branch from c78c56f to 3c8e980 Compare May 6, 2026 10:15
@mostafa mostafa merged commit 176a8c7 into main May 6, 2026
9 checks passed
@mostafa mostafa deleted the fix/security-critical branch May 6, 2026 10:44
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