Skip to content

Security review (2026-11-15): SAML NameID spoofing exposure, agent signature integrity gap, unbounded pre-auth body read #892

Closed

Description

@fclairamb

Security review — 2026-11-15 (main @ 55775c6, v0.50.1)

Scope: Go backend (server/), agent protocol, OAuth/MCP surface, webhook callbacks, egress/SSRF policy, SQL access, CORS/redirects, uploads, security headers, Docker image. Method: govulncheck ./... + manual review of the authentication/authorization choke points and the public (unauthenticated) surfaces.

Overall assessment: the codebase is in very good security shape. Authz is enforced at documented choke points (RequireAuth/RequireOrgAccess/RequireOrgWrite with membership-row role reads), JWTs are HS256-pinned with issuer/expiry requirements and HKDF purpose-key separation, PATs are org-bound and hashed at rest, the egress guard pins resolved IPs against DNS rebinding, webhook callbacks are signature-verified before parsing, OAuth requires PKCE S256 and exact-match redirect URIs, and the runtime image is distroless nonroot. The findings below are the gaps that remain.

Per SECURITY.md, vulnerabilities normally go through private advisories — this issue was requested by the maintainer as a tracking issue; it contains no weaponized proof-of-concept. Happy to move any item to a private advisory.


1. [Medium] SAML: crewjam/saml advisory GO-2026-6909 — NameID spoofing reachable through the email fallback

govulncheck reports GO-2026-6909 against github.com/crewjam/[email protected] (no fixed version published):

  1. validateAssertion nil-pointer panic when a signed assertion omits <saml:Issuer> and ExpectedIDPEntityID is set.
  2. Subject uses the bare XML tag xml:"NameID", which matches <NameID> in any XML namespace: a signed assertion that omits <saml:NameID> but carries a foreign-namespace <NameID> inside <saml:Subject> populates Subject.NameID.Value from the foreign element.

Reachability in SolidPing:

  • internal/handlers/auth/saml_service.go:532 — HandleACS → spClient.ParseResponse (the flagged symbol).
  • Variant 1 is not reachable as configured: spBase never sets ExpectedIDPEntityID.
  • Variant 2 is relevant: mapAssertion (saml_service.go:567) reads Subject.NameID.Value, uses it as the provider link ID, and falls back to it as the account email when it contains @. findOrCreateUser (saml_service.go:636) then links/creates accounts by email — the code comment explicitly trusts the email because "the assertion has already passed full signature/Conditions/Audience validation". The namespace-blind parsing weakens exactly that assumption: a malicious or compromised IdP can mint a signature-valid assertion whose effective NameID/email is a victim's address, yielding session minting for an existing account (including accounts that never used SAML, up to super admins).

Preconditions: SAML enabled (default off, instance-wide config) and a malicious/compromised configured IdP — hence Medium, not High.

Recommendations

  • Drop or gate the NameID→email fallback: require the email to come from an explicit, mapped SAML attribute (the EmailAttribute config already exists).
  • Optionally validate in the raw assertion XML that Subject/NameID is in the SAML assertion namespace before trusting it.
  • Track upstream for a fix; consider a pinned fork/replace until one ships (the repo already vendors a patched grdp, so the pattern exists).
  • Setting ExpectedIDPEntityID would be good hygiene but note it activates variant 1's precondition while the upstream bug is unfixed — do it together with the upgrade/fork.

2. [Medium] Agent HTTP request signatures cover neither the body nor the query string

The agent's Ed25519 scheme signs method|path|timestamp|nonce only:

  • internal/agents/crypto.go:84 — SignatureChallenge.
  • internal/handlers/agentauth/agentauth.go — verifies against req.URL.Path (query excluded).

It was designed for the WebSocket reconnect (no body, no query), but the same scheme now authenticates plain HTTP calls that carry both:

  • internal/checkworker/backend/ws_capture.go:141 — attachment upload: POST /api/v1/agent/attachments?topic=<topic> with the capture blob (screenshot / path trace) as body. Neither topic nor the blob is signed.
  • internal/checkworker/backend/ws_tasks.go:155 — worker-task claim/step/finish/fail POSTs: the JSON bodies (task claims, results, failures) are not signed.

httpBaseURL (ws_capture.go) explicitly supports ws:// → http://, i.e. plain HTTP is a supported agent configuration. An on-path attacker there can rewrite the topic parameter or swap the body of a validly-signed, nonce-fresh request: the nonce guard stops replay but not in-flight tampering. Impact: integrity of monitoring evidence (screenshots/traces) and of worker-task results. Over TLS the transport closes the gap, but the signature scheme itself provides no end-to-end body integrity — unlike internal/servicesig, which already hashes the exact body bytes.

Recommendation: extend the challenge to method|full-request-URI(path+query)|timestamp|nonce|sha256(body) (empty-body hash for bodyless calls), mirroring servicesig. Version the scheme (e.g. a header or challenge prefix) so old agents fail closed during rollout rather than silently verifying the old format.

3. [Low] Unbounded pre-auth body buffering in ServiceSignature

internal/middleware/auth.go:526 — readAndRestoreBody does io.ReadAll(req.Body) with no size cap, and it runs before authentication whenever X-SP-Signature is present (servicesig.HasSignature only checks the header is non-empty).

The middleware is mounted on the public API group /api/v1/orgs/:org/entitlements (server.go:1965). Any unauthenticated caller can send that header plus an arbitrarily large body and make the server buffer it fully in memory before the signature check rejects the request. There is no global body limit (limits are per-handler: webhooks, bulk checks, feedback, heartbeat, logos, assets), and ReadHeaderTimeout does not bound the body. Repeated/parallel requests → memory exhaustion on directly-exposed self-hosted instances (SaaS depends on ingress limits).

Recommendation: wrap the body in http.MaxBytesReader (a few MiB is generous for entitlements writes) inside readAndRestoreBody, or apply a global body cap middleware ahead of the signature check.

4. [Info / hardening] Known dev JWT secret passes the placeholder check

ensureJWTSecret (internal/systemconfig/systemconfig.go:1604) auto-generates a secret only when the configured value is empty or exactly change-me-in-production. The repo's dev docker-compose.yml sets SP_AUTH_JWT_SECRET=dev-secret-change-in-production — a publicly known constant that the check treats as a real secret. The published docs' production compose example correctly omits the variable (auto-generation kicks in), but anyone copying the repo's dev compose into production gets a world-readable JWT signing key → session forgery for any account.

Recommendation: extend the placeholder detection to known dev values (or warn loudly at startup when the secret matches one), and/or label the dev compose file unmistakably as dev-only.


Checked and found sound (non-exhaustive)

  • JWT validation: HS256 allowlist, issuer + expiry required, purpose claim refused on bearer tokens; HKDF purpose keys; PAT cache keyed by hash; org binding enforced at the choke point.
  • Authorization: membership-row role reads (demotion effective immediately), viewer write floor, impersonation/PAT/demo denylists applied centrally, super-admin impersonation refused.
  • OAuth/MCP: PKCE S256 mandatory, exact-match redirect URIs (loopback port exception), RFC 8707 audience binding, MCP credentials refused on REST, dynamic registration validates redirect URIs.
  • Egress: dial-layer guard with IP pinning + Control re-check (DNS-rebinding safe), full non-public range table incl. cloud metadata, IPv6 transition forms; public /tools/run hardwired to refuse private targets regardless of SP_EGRESS_ALLOW_PRIVATE, per-IP minute+day limits, concurrency cap, result cache.
  • Webhooks: Twilio signature over exact URL+params, WhatsApp HMAC over raw body before parsing, Telegram constant-time secret-token check before parse with bounded body, OVH path-secret derived via HMAC from the JWT secret.
  • Post-login redirects: same-origin-only with backslash/control-char/protocol-relative defenses; CORS never pairs * with credentials, exact-origin allowlist.
  • SQL: parameterized via bun; the two fmt.Sprintf raw queries interpolate an int only.
  • Runtime: distroless nonroot, healthcheck without shell, per-handler upload caps, security headers/CSP module, test-mode fixture routes gated by RunMode.

Suggested priority

  1. feat: batch 02 - 18 new check types, notifications, and integrations #3 (trivial fix, unauthenticated DoS) — quick win.
  2. chore(release): v1.0.0 #2 (signature scheme extension, needs agent/server rollout coordination).
  3. feat: custom user-agent, refresh checks, vite plugin switch, CI updates #1 (remove NameID→email fallback now; track upstream fix).
  4. chore(release): v0.1.0 #4 (startup guard, documentation).

Activity

  1. fclairamb commented on Nov 15, 2026

    @fclairamb
    OwnerAuthor

    One PR per finding, all targeting main:

    Finding PR
    3 — unbounded pre-auth body read in ServiceSignature #894
    4 — known dev JWT secret passes the placeholder check #895
    1 — SAML NameID spoofing (GO-2026-6909) #896
    2 — agent signatures: bind query + body (v2 challenge) #897

    Each PR is self-contained with tests; #894 and #895 are independent quick wins, #896 is SAML-only (default off), #897 needs the server-before-agent rollout noted in its description. None is labelled automerge — security changes, maintainer review first.

  2. added a commit that references this issue on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions