Den vollständigen Index der Dokumentation findest du in llms.txt. Die Markdown-Version einer Dokumentationsseite erhältst du, indem du .md an die URL der Seite anhängst.
Hauptnavigation
Design
Codex

Anwendungsfall für Codex

Sicherheitskontext einrichten

Lege fest, was du schützen willst, welche Regeln Codex prüfen soll und was in den Bericht gehört.

Schwierigkeitsgrad Intermediate
Zeithorizont 30m

Erfahre, wie du den Kontext vorbereitest und konfigurierst, den Codex für Sicherheitsprüfungen und Scans braucht.

Besonders geeignet für

  • Entwickelnde, die ein Repository für Sicherheitsprüfungen und Scans vorbereiten.
  • Teams für Anwendungssicherheit, die Systemrisiken, Sicherheitsanforderungen und Meldekriterien dokumentieren.
  • Teams, die Sicherheitsagenten ihr Wissen über Architektur, Entwicklung und Betrieb zur Verfügung stellen.

Inhalt

    ← Alle Anwendungsfälle

    Sicherheitskontext einrichten

    Lege fest, was du schützen willst, welche Regeln Codex prüfen soll und was in den Bericht gehört.

    Erfahre, wie du den Kontext vorbereitest und konfigurierst, den Codex für Sicherheitsprüfungen und Scans braucht.

    Intermediate
    30m

    Besonders geeignet für

    • Entwickelnde, die ein Repository für Sicherheitsprüfungen und Scans vorbereiten.
    • Teams für Anwendungssicherheit, die Systemrisiken, Sicherheitsanforderungen und Meldekriterien dokumentieren.
    • Teams, die Sicherheitsagenten ihr Wissen über Architektur, Entwicklung und Betrieb zur Verfügung stellen.

    Skills und Plug-ins

    Skill Nutzen
    Codex Security:threat Model Erstelle für deine Anwendung ein Bedrohungsmodell, das schützenswerte Ressourcen, Einstiegspunkte, Sicherheitsgrenzen und zugrunde liegende Annahmen erfasst.
    Codex Security:define Security Policy Erstelle eine Sicherheitsrichtlinie und hinterlege sie in deinem Repository.

    Unterschiede zwischen Bedrohungsmodellen, AGENTS.md, SECURITY.md und Wissensbasen

    In AGENTS.md hältst du gemeinsame Vorgaben für die Entwicklung fest, damit im Team dieselben Erwartungen gelten. In SECURITY.md legt deine Organisation fest, wie Codex Sicherheitsrisiken bewerten und Befunde melden soll. Ein Bedrohungsmodell beschreibt, welchen Bedrohungen das System ausgesetzt ist. Bedrohungsmodell und Sicherheitsrichtlinie überschneiden sich, aber das Bedrohungsmodell ist in der Regel nur ein Teil der umfassenderen Richtlinie.

    Ein Bedrohungsmodell beschreibt zum Beispiel schützenswerte Ressourcen, Einstiegspunkte, Eingaben, die Angreifende kontrollieren können, Vertrauensgrenzen, Annahmen zur Authentifizierung, privilegierte Vorgänge und Komponenten mit erhöhtem Risiko.

    # Threat Model
    
    The public API accepts untrusted JSON and file uploads.
    Requests cross from the internet-facing API into internal billing and
    identity services. Attackers are unauthenticated users or compromised
    tenant accounts. Protect tenant data, billing mutations, and service credentials.

    In security.md legt deine Organisation fest, wie Codex die beschriebenen Risiken bewerten und welche Befunde es melden soll.

    # Security Policy
    
    ## Security Invariants
    
    - Every billing mutation must be authorized for the active tenant.
    - Uploaded content must be parsed within explicit size and resource limits.
    - Service credentials must never be returned to clients.
    
    ## Reportable Findings
    
    Report realistic violations of tenant isolation, authentication bypass,
    unsafe parsing, secret exposure, or unauthorized billing mutations.
    
    ## Severity Context
    
    Cross-tenant access is Critical.
    Single-tenant unauthorized mutation is High.
    
    ## Out of Scope
    
    Development-only tools that cannot be included in production builds.

    Über eine Wissensbasis kannst du für einzelne Scans ergänzende Unterlagen bereitstellen. Dazu gehören etwa Architekturdokumente, Richtlinien, weitere Bedrohungsmodelle oder Informationen zum Betrieb, die der CLI-Scanner berücksichtigen soll. Das folgende Beispiel zeigt ein Architekturdokument in Markdown, das dem CLI-Scanner als Grundlage dient.

    # Payment Service Security Context
    
    ## Purpose
    
    The payment service creates charges, issues refunds, and stores references
    to payment-provider customers. It does not store full card numbers or CVVs.
    
    ## Deployment and Exposure
    
    - `POST /api/payments` is internet-facing through the API gateway.
    - `POST /internal/refunds` is reachable only from the support service.
    - Background workers consume messages from the `payment-events` queue.
    - The service runs with access to the payment-provider API and billing database.
    
    ## Authentication and Authorization
    
    - Public endpoints use JWTs issued by the identity service.
    - The API gateway validates signatures, issuer, and expiration.
    - This service remains responsible for tenant authorization.
    - Internal requests use workload identity; network location alone is not trusted.
    - Refunds above £1,000 require a previously recorded approval.
    
    ## Trust Boundaries
    
    1. Internet client → API gateway
    2. API gateway → payment service
    3. Payment service → payment provider
    4. Payment service → billing database
    5. Message producers → `payment-events` consumer
    
    Inputs crossing any of these boundaries must be treated as untrusted unless
    the receiving component performs the documented validation.
    
    ## Sensitive Assets and Operations
    
    - Payment-provider API credentials
    - Customer-to-provider identifier mappings
    - Charge creation
    - Refund issuance
    - Webhook signature secrets
    - Tenant billing history
    
    ## Important Data Flows
    
    ### Creating a charge
    
    1. The API receives an authenticated request containing an order identifier.
    2. The service retrieves the order using both tenant ID and order ID.
    3. The service calculates the amount from server-side order data.
    4. The service creates the provider charge with an idempotency key.
    5. The resulting provider identifier is stored in the billing database.
    
    Client-supplied amounts must never be passed directly to the provider.
    
    ### Processing a webhook
    
    1. The raw request body is retained.
    2. The provider signature is verified over the raw bytes.
    3. The event timestamp must be within five minutes.
    4. Duplicate event IDs are ignored.
    5. State changes occur only after all validation succeeds.
    
    ## Relevant Code
    
    - `src/http/payments.ts`: public payment endpoints
    - `src/http/refunds.ts`: refund endpoints
    - `src/webhooks/provider.ts`: webhook validation
    - `src/workers/payment-events.ts`: asynchronous event processing
    - `src/auth/tenant.ts`: tenant authorization
    - `src/provider/client.ts`: provider API wrapper
    
    ## Security Assumptions
    
    - The identity service is trusted to authenticate users, but not to authorize
      access to payment records.
    - Queue publishers may be compromised; consumers must validate message content.
    - API-gateway authentication does not replace service-level tenant checks.
    - Provider webhook payloads are attacker-controlled until signature validation
      completes.
    
    ## Known Limitations
    
    - Legacy refunds created before 2025 do not have idempotency keys.
    - Webhook replay protection is local to one region.
    - The development payment-provider emulator does not validate signatures.

    Mit folgendem Befehl stellst du die Wissensbasis für den Scan bereit:

    codex-security scan . \
      --knowledge-base /path/to/security-policies

    Die Dateien kannst du zum Beispiel so organisieren:

    SECURITY.md
    docs/security/
    ├── threat-model.md
    ├── architecture.md
    ├── authentication.md
    └── deployment-boundaries.md

    Ein Bedrohungsmodell anlegen

    Ein Bedrohungsmodell im Repository gibt Codex eine wichtige Grundlage für Sicherheitsprüfungen. Du kannst mit dem entsprechenden Skill in Codex ein erstes Bedrohungsmodell erstellen und es per Commit ins Repository aufnehmen.

    Beispielentwurf eines Bedrohungsmodells für ein Repository in einem Codex-Projekt.

    Gib in Codex $threat-model ein, um den Skill aufzurufen. Sobald das Bedrohungsmodell erstellt ist, nimm es per Commit unter /docs/security ins Repository auf. Verlinke es anschließend in den Einstellungen von Codex Cloud für das ausgewählte Repository. Wenn du kein Bedrohungsmodell angibst, erstellt Codex bei jeder Sicherheitsprüfung ein neues.

    Beispieleinstellungen für die Sicherheitsprüfung eines Demo-Repositorys.

    Eine SECURITY.md anlegen

    Mit dem Skill $define-security-policy kannst du im Repository eine erste Fassung der Sicherheitsrichtlinie erstellen.

    Prompt zum Erstellen einer Sicherheitsrichtlinie für die fiktive North Star Bank.

    Eine gute Sicherheitsrichtlinie beschreibt genau, wie die Anwendung funktioniert. Der folgende Beispiel-Prompt liefert Codex die nötigen Details, um die einzelnen Sicherheitsanforderungen zu benennen und in der Richtlinie festzuhalten:

    ### Authentication and Authorization
    
    - Every non-public endpoint must authenticate the caller.
    - Sessions and tokens must be validated for issuer, audience, signature, expiry, revocation, and intended authentication context.
    - Authentication failures must fail closed.
    - Sensitive operations must require recent or stronger authentication where appropriate.
    - Password-reset, account-recovery, MFA, and identity-linking flows must not permit account takeover.
    - Authentication secrets and tokens must never appear in logs, URLs, analytics, or error responses.
    - Authorization must occur before every read, mutation, transaction, export, or administrative action.
    - Possession of a valid account or resource identifier never proves authorization.
    - Customer, account, and tenant isolation must hold across list, detail, search, bulk, export, and indirect-reference endpoints.
    - Server-side authorization must not rely on client-supplied roles, ownership fields, prices, balances, or approval state.
    - Administrative and service-to-service permissions must use least privilege.
    - Failures allowing cross-customer access are reportable even when only one endpoint is affected.
    
    ### Transaction and ledger integrity
    
    - Transactions must be authorized against the authenticated customer and eligible source account.
    - Amounts, currencies, destinations, fees, limits, and approval state must be validated server-side.
    - Transaction requests must be protected against replay, duplication, race conditions, and idempotency-key confusion.
    - Balance checks and ledger updates must be atomic.
    - Posted ledger entries must be immutable or corrected through auditable compensating entries.
    - High-risk transactions must enforce applicable limits, step-up authentication, approval, or fraud controls.
    - No failure path may produce an ambiguous transaction state without reconciliation.
    
    ### Data protection
    
    - Sensitive data must be encrypted in transit and at rest using approved controls.
    - Secret material must come from an approved secret-management system rather than source code or ordinary configuration files.
    - Logs, traces, metrics, support tooling, and security artifacts must exclude credentials and minimize personal and financial data.
    - Data exports and backups must receive equivalent authorization and protection to primary data.
    - Error responses must not expose internals, sensitive records, credentials, or authorization details.
    - Retention and deletion behavior must follow the system’s approved data-governance requirements.
    
    ### Input and output handling
    
    - Treat headers, paths, query parameters, bodies, uploaded files, webhook payloads, third-party responses, and stored customer content as untrusted.
    - Apply schema, type, range, length, and format validation before security-sensitive use.
    - Database access must use parameterized queries.
    - Outbound requests must restrict destinations, protocols, redirects, DNS behavior, and response sizes.
    - Parsers, uploads, decompression, and serialization must be bounded against resource exhaustion.
    - Customer-controlled content must be safely encoded for its output context.
      \

    Verwandte Anwendungsfälle