fix: redact stored webhook authorization headers and other secret fields by key name (SEC-02)
This commit is contained in:
1 parent
d5ca530db3
commit
5b622e64e2
4 files changed
+201
-2
No files matched your search
@@ -13,6 +13,9 @@ Security properties (all covered by tests):
|
||||
* the identity token and ``Identity.redact``, the configured Gitea token, the MCP bearer token, the
|
||||
OAuth client secret, ``extra_secrets`` and secret values submitted in a
|
||||
request body are replaced with ``[REDACTED]`` in every result, always;
|
||||
* secret-bearing response fields (:data:`~.encoding.SENSITIVE_RESPONSE_KEYS`, for example a
|
||||
webhook's stored ``authorization_header``) are redacted by key name in every result except
|
||||
those of :data:`CREDENTIAL_ISSUING_OPERATIONS`, whatever ``SECRET_DETECTION_MODE`` says;
|
||||
* secret-pattern masking/blocking follows ``SECRET_DETECTION_MODE``, except for
|
||||
:data:`CREDENTIAL_ISSUING_OPERATIONS` whose purpose is to return a freshly
|
||||
minted credential (exact redaction still applies there);
|
||||
@@ -38,6 +41,7 @@ from aegis_gitea_mcp.config import Settings
|
||||
from aegis_gitea_mcp.errors import kind_for_status, sanitize_message
|
||||
from aegis_gitea_mcp.gitea.encoding import (
|
||||
RAW_METHODS,
|
||||
SENSITIVE_RESPONSE_KEYS,
|
||||
ArgumentError,
|
||||
PayloadTooLargeError,
|
||||
RequestBody,
|
||||
@@ -50,7 +54,12 @@ from aegis_gitea_mcp.gitea.encoding import (
|
||||
validate_sudo,
|
||||
)
|
||||
from aegis_gitea_mcp.gitea.pagination import build_pagination
|
||||
from aegis_gitea_mcp.gitea.redaction import normalize_secrets, redact_exact, redact_text
|
||||
from aegis_gitea_mcp.gitea.redaction import (
|
||||
normalize_secrets,
|
||||
redact_exact,
|
||||
redact_fields,
|
||||
redact_text,
|
||||
)
|
||||
from aegis_gitea_mcp.identity import Identity
|
||||
from aegis_gitea_mcp.security import sanitize_data
|
||||
|
||||
@@ -613,6 +622,10 @@ class GiteaExecutor:
|
||||
"""Redact, mask or block, and bound the payload size."""
|
||||
secrets = self._secrets(identity, call)
|
||||
payload = redact_exact(payload, secrets)
|
||||
if not exempt and "data" in payload:
|
||||
# Stored secrets (webhook authorization headers, ...) by field name: pattern
|
||||
# masking cannot recognise them and SECRET_DETECTION_MODE may be off.
|
||||
payload = {**payload, "data": redact_fields(payload["data"], SENSITIVE_RESPONSE_KEYS)}
|
||||
mode = self._settings.secret_detection_mode
|
||||
if mode != "off" and not exempt:
|
||||
if mode == "block":
|
||||
|
||||
Reference in new issue
Block a user