Skip to content

Validate cloud profile picture URL origin before rendering #64

@chefsale

Description

@chefsale

Context

Bugbot flagged on PR #52 (comment 3104931747).

Problem

apps/desktop/src/pages/Settings.tsx renders cloudPicture directly as an <img src={...}>. The URL comes from the Google ID token's picture claim, which we decode client-side without signature verification. If a malicious calimero:// deep link slipped through all our other validation, a crafted JWT could point picture at an attacker-controlled host — the <img> request would fire and leak the user's IP / time-of-use.

CSRF state on the OAuth flow and server-side token validation make this hard to reach in practice. This is defense-in-depth.

Scope

Two options:

  • Allow-list: check the URL origin against known Google avatar hosts (*.googleusercontent.com, lh3.googleusercontent.com, etc.) and refuse to render if it doesn't match. Fall back to a generated initials avatar.
  • Proxy through backend: never render the URL directly; fetch it via proxy_http_request (for cache / CSP purposes). Heavier.

Start with the allow-list approach. Ten lines of code in a small isTrustedAvatarHost util.

Priority

Low. User-impact is minimal; attacker needs to have already compromised the OAuth/deep-link path. Worth landing in a general hardening pass rather than a dedicated PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions