Repo config redirects VEANS_TOKEN to an attacker-chosen server
Description
Affects all veans versions (veans has no tagged release yet).
Summary
veans takes the Vikunja server URL from the nearest .veans.yml, walking up from the working directory. When VEANS_TOKEN is set, veans sends it as a Bearer token to whatever server that file names. Running any veans command in an untrusted repo, or CI running veans on PR code, hands the token to the repo author's server.
Details
EnvBackend.Getreturns the env token regardless of server/account (veans/internal/credentials/env.go:29).config.Findwalks up from cwd (veans/internal/config/config.go:102), andloadRuntimepassescfg.Serverto the client (veans/internal/commands/runtime.go:57,63).- The client adds the Bearer header with no origin check (
veans/internal/client/client.go:106,128). primetriggers such a request (veans/internal/commands/prime.go:78), and the agent hooks run it on every session start.- Keyring and file tokens are keyed by server (
veans/internal/credentials/store.go:57), so only the env token leaks.
Impact
The attacker gets the victim's Vikunja API token and whatever access it carries on the real server. Requires VEANS_TOKEN in the environment (typically CI) and veans running in an attacker-controlled checkout.
Fix
Add a trust gate: one origin check in the client/runtime setup (veans/internal/commands/runtime.go:57-63, veans/internal/commands/login.go:69), run before any env token is attached, any human credential is sent (password, token, or opening the OAuth browser), or any remote metadata is fetched for the prompt.
- Trust records live in global XDG state, never repo-local (an attacker repo could ship a pre-approved one). They are keyed by normalized origin (scheme + host + port) plus repo identity, so an
httpsrecord doesn't cover a downgradedhttporigin. - Interactive commands show the normalized origin and ask once; "yes" records it.
veans initwith a user-typed server records trust without asking. - Non-interactive runs (the SessionStart/PreCompact hook running
prime, CI) never prompt and fail closed. - In CI, a
VEANS_SERVERenv var whose origin matchescfg.Servercounts as a trust record.
Attach VEANS_TOKEN only to a trusted origin: an interactive trust record, or, in CI (veans/internal/credentials/env.go:21-23), a matching VEANS_SERVER. With neither, veans refuses and doesn't prompt.
Found via internal security review (csf #2, f2 #3, 03 #12, 04 #9, deep #13).
Folded in: veans login sends human credentials to a repo-selected server (was GHSA-2mwp-p5v5-3gcm)
Same root cause, same trust gate. A teammate runs veans login in a cloned repo, as veans itself tells them to (veans/internal/commands/runtime.go:60). Their password, TOTP code or token goes to the server named in the repo's .veans.yml; in OAuth mode they land on a sign-in page hosted by that server. login.go:56,69 (config.Find → client.New(cfg.Server, "")) has no origin confirmation, the password prompt is generic (auth.go:143) before the POST (:152), and the server is named only after success (login.go:109). The gate must run before AcquireHumanToken, which covers password, token and OAuth modes.
Gate requirements found in verification: normalize with net/url and reject userinfo (client.New string-concatenates BaseURL, so https://trusted.example@evil.example/ currently goes to evil.example); run it before store.Get in loadRuntime, because backfillFrontendURL (runtime.go:72-74) sends an authenticated request inside loadRuntime itself; store the record under a fixed ~/.config/veans/ path with no XDG env override.