HTTP-Methoden-Validierung

8 Tests verifizieren, dass nur erlaubte HTTP-Methoden pro Pfad akzeptiert werden.

Konfiguration

HTTP-Methoden werden pro Pfad in policy.yaml konfiguriert:

# policy.yaml
paths:
  - pattern: "/static/*"
    methods: ["GET", "HEAD"]

  - pattern: "/api/users"
    methods: ["GET", "POST"]

  - pattern: "/api/users/{id}"
    methods: ["GET", "PUT", "DELETE"]

# Global: Gefährliche Methoden blockieren
blocked_methods:
  - "TRACE"    # XST-Angriffe verhindern
  - "CONNECT"  # Proxy-Missbrauch verhindern
METHOD-001PASS

GET /static/style.css - Erlaubte Methode

Beispielanfrage

curl -X GET http://localhost:8080/static/style.css

GET-Anfragen an statische Dateien sind laut Policy erlaubt. Die Anfrage wird an das Backend weitergeleitet.

METHOD-002PASS

POST /api/users - Erlaubte Methode

Beispielanfrage

curl -X POST -d '{"name": "Max"}' http://localhost:8080/api/users

POST-Anfragen an /api/users sind zum Erstellen neuer Benutzer erlaubt.

METHOD-003BLOCKIERT

DELETE /static/style.css - Methode nicht erlaubt

Beispielanfrage

curl -X DELETE http://localhost:8080/static/style.css

Erwartete Antwort

HTTP/1.1 405 Method Not Allowed
Allow: GET, HEAD

{"error": "Methode nicht erlaubt", "allowed": ["GET", "HEAD"]}

DELETE-Anfragen an statische Dateien werden blockiert. Die Antwort enthält den Allow-Header mit erlaubten Methoden.

METHOD-005BLOCKIERT

TRACE /api/users - Gefährliche Methode blockiert

Beispielanfrage

curl -X TRACE http://localhost:8080/api/users

TRACE und andere potenziell gefährliche Methoden werden standardmäßig blockiert, um XST-Angriffe (Cross-Site Tracing) zu verhindern.