Skip to content

security(connectors): complete Phase 5.6 read-only enforcement and safety qualification - #48

Closed
krishanth7 wants to merge 2 commits into
feat/phase-5.5-metadata-normalization-identityfrom
security/phase-5.6-connector-safety
Closed

krishanth7 wants to merge 2 commits into
feat/phase-5.5-metadata-normalization-identityfrom
security/phase-5.6-connector-safety

Conversation

@krishanth7

@krishanth7 krishanth7 commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

This pull request completes Phase 5.6: Read-Only Enforcement, Timeouts & Safety and achieves final milestone certification for Phase 5: Database Connectors & Metadata Inspection for DERA (Database Engineering & Reverse Analysis). It establishes a unified, fail-closed security subsystem across PostgreSQL, Supabase, SQLite, MySQL, and MariaDB connectors, guaranteeing read-only metadata inspection, SSRF egress protection, DNS rebinding defense, SQLite filesystem containment, multi-tenant workspace isolation, centralized timeout budgets, and cooperative cancellation.

Change Type

  • Feature (feat)
  • Bug fix (fix)
  • Documentation (docs)
  • Refactor (refactor)
  • Performance (perf)
  • Test improvement (test)
  • CI/CD or Build (ci, build)
  • Security enhancement (security)
  • Breaking change (!)

Related Issues

Closes #42
Completes Phase 5.6 Engineering Implementation Directive
Certifies Phase 5 Completion (docs/audit/PHASE_5_COMPLETION.md)

Implementation Details

  • Established modular security subsystem in packages/connectors/src/dera_connectors/security/:
    • policy.py: Unified ConnectorSecurityPolicy orchestrating tenant authorization, destination validation, and query allowlists.
    • readonly.py: Static lexical analysis, comment stripping (/* ... */, --, #), single-quote literal replacement, and DDL/DML mutation keyword blocking.
    • query_policy.py: ApprovedMetadataQueryRegistry governing pre-registered catalog queries with parameter validation and row caps.
    • destinations.py: Strict SSRF boundaries blocking cloud metadata (169.254.169.254), loopbacks, private subnets, dangerous service ports, and destination IP pinning.
    • credentials.py: Safe DatabaseCredentials container with repr=False, null byte detection, and ephemeral resolution.
    • authorization.py: Multi-tenant workspace authorization (validate_workspace_authorization) enforced before secret resolution.
    • isolation.py: SQLite path canonicalization (os.path.realpath), approved storage root containment, symlink escape checks, Windows device blocking (CON, PRN, NUL), and deterministic mode=ro URI generation.
    • timeouts.py: TimeoutBudget and monotonic DeadlineTracker propagating overall deadlines (default 120s) across multi-step inspections.
    • cancellation.py: EnhancedCancellationToken supporting parent-child propagation, driver interrupt callbacks, and transaction rollbacks.
    • resource_limits.py: Explicit caps on result rows (50,000), identifier lengths (1,024), SQL definition sizes (1MB), and total schema entities (100,000).
    • redaction.py: Recursive credential scrubbing (sanitize_diagnostics) and regex masking (mask_sensitive_strings).
    • audit.py: Structured security audit logging (log_security_audit_event) capturing forensic records without secret leakage.
  • Authored 12 security architecture and testing specifications in docs/security/.
  • Authored docs/audit/PHASE_5_6_SECURITY_BASELINE.md, docs/audit/PHASE_5_6_SECURITY_ACCEPTANCE.md, and docs/audit/PHASE_5_COMPLETION.md.

Testing

  • Relevant tests passed (python scripts/development/dev.py all or test)
  • Tests not applicable — explanation below
  • Tests not run / blocked — explanation below

Test evidence & notes:

  • Executed unit, network, filesystem, tenant isolation, and integration safety tests:
    • tests/security/connectors/: 23 passed
    • tests/security/network/: 8 passed
    • tests/security/filesystem/: 7 passed
    • tests/security/tenancy/: 4 passed
    • tests/integration/connector_safety/: 7 passed
    • tests/regression/connectors/: 4 passed
    • tests/security/ (platform security): 20 passed
  • Full repository test suite passed with 587 tests:
    Ran 587 tests in 67.782s
    OK (skipped=2)
    
  • Documentation linting (npm run docs:lint) passed with 0 issues in 291 files.
  • Documentation link verification (python scripts/ci/validate_docs.py) passed.

Documentation Impact

  • Documentation in docs/ updated or verified where required
  • Documentation validation passed (npm run docs:check)
  • No documentation updates required for this change

Security Impact & Deterministic Engineering

  • Strict Non-AI Policy: Verified zero generative AI, LLM, or external inference APIs are introduced.
  • Database Safety: Verified all database connector operations enforce read-only introspection without data modification.
  • Credential Protection: Confirmed that no production credentials, passwords, or .env secrets are committed.
  • Least Privilege: Validated that permissions and access boundaries are minimized.
  • No Security Impact: Change does not affect database connections, security boundaries, or credentials.

Security Assessment Note:

  • Completed STRIDE threat model evaluating 18 threat vectors (docs/security/CONNECTOR_THREAT_MODEL.md).
  • Implemented read-only lexical analysis, SSRF egress filtering, destination IP pinning, SQLite root containment, workspace isolation, centralized deadlines, and non-retryable security error classification.

Breaking Changes

  • No breaking changes.
  • Breaking change introduced (detailed explanation and migration path below):

Contributor Checklist

  • My code adheres to the project's coding standards (PEP 8, TypeScript strict mode).
  • My branch is rebased on the latest main branch.
  • The PR title follows Conventional Commits (e.g., feat(connectors): add SQLite metadata support).
  • No unrelated changes or accidental files are included.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@krishanth7
krishanth7 added this pull request to stack #49 October 27, 2026 15:38
@krishanth7
krishanth7 force-pushed the security/phase-5.6-connector-safety branch from 3552578 to 027c52c Compare October 27, 2026 15:38
The cross-engine connector safety regression tests added in Phase 5.6
import dera_connectors (packages/connectors/src) but the schema-regression
workflow only exposed packages/core/src and apps/api/src on PYTHONPATH,
causing a ModuleNotFoundError and CI failure on PR #48.

Changes:
- Add packages/connectors/src to PYTHONPATH env for the regression step
- Install asyncpg/aiomysql/aiosqlite/cryptography before running tests
- Extend path triggers to include packages/connectors/src/** so the
  regression suite re-runs whenever connector source files change
@krishanth7

Copy link
Copy Markdown
Owner Author

All Phase 5.6 commits have been merged into main via fast-forward (commits 027c52c and 3730ed7). The security/phase-5.6-connector-safety branch is fully integrated. CI workflow fix (dera_connectors PYTHONPATH) is also live on main.

@krishanth7 krishanth7 closed this Oct 27, 2026
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