Security: host-agnostic token (MADTEA_TOKEN env / plaintext madtea.token) attaches to origin-derived forge URL - untrusted-clone exfiltration #271
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea#271
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A credential-lifecycle audit found a real token-exfiltration path that the host-keyed secure backends are specifically designed to prevent, but which the two host-agnostic token sources sidestep.
Mechanism (verified in code):
internal/config/config.go:182-184-resolveSecureOrGitTokenreturnsMADTEA_TOKENunconditionally for whatever URL was already resolved (to enable non-interactive use), with no host association.internal/config/config.go:240-248- step 3 reads the plaintextmadtea.tokenvia a merged git-config view (getGitConfigValue("--get","madtea.token")) - also unscoped to any host.getConfigFromGit->OriginForgeURL), so in a freshly cloned repo the forge host comes fromorigin, which is attacker-controlled.internal/gitea/client_http.go:102-104then attachesAuthorization: token <token>because the request is same-origin with that origin-derivedbaseURL. The secure-scheme check does not help -https://attackerpasses.Attack scenario: operator has
MADTEA_TOKENexported (noMADTEA_URL), or uses a--insecure-storageplaintext token. They clonehttps://attacker.example/repo, cd in, and run any networked madtea command (issue list,pr list, ...). madtea auto-detects the forge from origin and sends the operator's real token toattacker.example.Severity: medium. Contrast with the host-keyed secure backends (keychain/pass/systemd-creds), where
Retrieve(host)misses for an unknown host and fails safe - this is exactly the gap ADR 0025 host-keying closes, and the env + plaintext paths bypass it. gh/glab scope tokens per host and would not do this. Mitigations that lower severity: the default is a host-keyed secure backend (safe); plaintext requires explicit--insecure-storage; the env-only case requires running a command inside an untrusted clone. No ADR treats the origin-derived URL as an accepted trust boundary, so this does not look consciously accepted.Fix direction: when the token source is host-agnostic, confirm the resolved forge host against a recorded/expected host before attaching the token, or require
MADTEA_URLalongsideMADTEA_TOKENrather than accepting an origin-derived URL for a host-agnostic token.Acceptance: a host-agnostic token is not sent to a forge host derived solely from a clone's origin; a regression test points at a foreign host and asserts the token is withheld.
auth loginshould ask which scope/level to store credentials at #419