Skip to content

security: bind view-state ids to a host-minted claim token (cross-view secret disclosure) #2151

Open

Description

@easonLiangWorldedtech

Context

The vps2 view-state series lets the webview send its own viewStateId in webviewDidLaunch; the extension adopts it in ClineProvider.setViewStateId and loads that view's persisted viewStates entry (including provider profile secrets read from context.secrets) into the state posted back to the webview.

setViewStateId only refuses ids that are still held by a LIVE instance (getAllInstances over activeInstances). dispose() removes the instance but leaves the durable viewStates entry in place (clearPersistedViewState only runs in the reset path), so a compromised webview can adopt a closed view's id and receive that view's secrets. This is the Security Boundaries error on #1919, inherited from the series' replayed units (author: the store in F1a #1546 and the launch adoption in F1c #1552; 7 replayed units carry the adoption path).

Filed separately so the fix lands once in the owner unit and the replayed branches converge by refresh, instead of seven competing patches.

Proposed design (for maintainer review)

  • Durable viewStates entries gain an optional host-minted claimToken (e.g. crypto.randomUUID()), never generated or chosen by the webview.
  • setViewStateId rejects an id whose entry has no claim token or whose presented token does not match, BEFORE loadViewState/re-keying persisted state.
  • The launch protocol carries the claim back: the extension messages the webview with viewStateClaim and the webview only echoes it; a webview cannot mint one.
  • dispose() either revokes the entry's claim (invalidating stale ids) or the claim dies with the host instance, whichever is cheaper to reason about.

Acceptance criteria

References

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions