Skip to content

fix: add input validation for gateway policy CRUD endpoint (#370) - #378

Merged
akordavid373 merged 1 commit into
connect-boiz:mainfrom
daniel007-ai:fix/issue-370-policy-validation
Jul 29, 2026
Merged

fix: add input validation for gateway policy CRUD endpoint (#370)#378
akordavid373 merged 1 commit into
connect-boiz:mainfrom
daniel007-ai:fix/issue-370-policy-validation

Conversation

@daniel007-ai

@daniel007-ai daniel007-ai commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #370 - [HIGH] No Input Validation on Gateway Policy CRUD Endpoint — Arbitrary Policy Injection

Changes

  1. New file: backend/src/gateway/policyValidation.ts

    • Joi validation schema for policy CRUD payloads with strict mode (.unknown(false))
    • Prototype pollution detection via __proto__ and constructor key checks
    • ReDoS safety check for regex pattern values in rules
    • HTML/XSS sanitization for policy name and description fields
  2. Updated: backend/src/gateway/PrivacyApiGateway.ts

    • Added 100KB body size limiter middleware for /gateway/policies endpoint
    • Integrated validateAndSanitizePolicy into updatePolicy method
    • Added description field to PolicyConfig interface
  3. New file: backend/src/gateway/__tests__/PolicyValidation.test.ts

    • 48 comprehensive tests covering all injection vectors:
      • Prototype pollution (__proto__, constructor keys)
      • Unknown/extra fields (strict mode)
      • Missing required fields
      • Invalid rule attributes, operators, actions
      • Oversized values and excessive rules
      • XSS in name/description (HTML tags, script tags, javascript: protocol, onclick handlers)
      • ReDoS patterns (nested quantifiers, .., excessive alternation)
      • Transform rule validation
      • null/undefined/non-object payloads
      • Max rule bounds

Acceptance Criteria

…oiz#370)

- Add Joi validation schema for policy CRUD payloads with strict mode
- Validate policy rules: attribute, operator, value length, action enums
- Reject unknown/extra fields to prevent prototype pollution
- Add 100KB body size limiter for /gateway/policies endpoint
- Sanitize HTML/script tags from policy name and description
- Add ReDoS safety check for regex pattern values
- Comprehensive tests for all injection vectors (48 tests)
@akordavid373
akordavid373 merged commit f8429c0 into connect-boiz:main Jul 29, 2026
8 checks passed
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.

[HIGH] No Input Validation on Gateway Policy CRUD Endpoint — Arbitrary Policy Injection

2 participants