Skip to content

fix(ci): load Figma file pages over pinned REST - #1032

Closed
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/bc-27fc307f-0d86-4832-bfff-e7f5a1b3fb31-5c19
Closed

fix(ci): load Figma file pages over pinned REST#1032
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/bc-27fc307f-0d86-4832-bfff-e7f5a1b3fb31-5c19

Conversation

@cursor

@cursor cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Successor to #1028. Cloud Agents still cannot finish Figma MCP OAuth. Whoami alone leaves the buyer unable to read a design file. This helper now verifies FIGMA_ACCESS_TOKEN and loads one file at GET /v1/files/:key?depth=1 so the next action is a named page, node, or image request.

  • Pin http.client.HTTPSConnection("api.figma.com") (no urllib.request.urlopen).
  • Allow only the X-Figma-Token header so a Host override cannot retarget TLS.
  • Accept 8–128 alphanumeric file keys from the Figma URL; refuse .., slashes, and query characters (CWE-22).
  • Cap whoami bodies at 64 KiB and file bodies at 8 MiB.
  • Prefer a plan access token for org Cloud Agent fleets; personal tokens remain valid in the same secret.
  • Doctoring, AGENTS.md, ARCHITECTURE.md, and CHANGELOG.md record the two-path auth and APA 7th citations.

Prefer this PR over #1028. Do not merge #1028 in parallel.

Developer experience

  • python3 scripts/ci/figma_rest_auth.py still proves the secret without printing it.
  • python3 scripts/ci/figma_rest_auth.py --file FILE_KEY prints page names plus component and style counts.
  • Semgrep dynamic-urllib-use-detected stays inapplicable.

User experience

  • Desktop/CLI keep full Figma MCP.
  • Cloud Agents can inventory the file the buyer linked once FIGMA_ACCESS_TOKEN is set.
  • Next action after a successful --file run: pick a page and request that node or its images over REST.

Test plan

  • tests/test_figma_rest_auth.py — missing/empty token, 200/401/403/404/503, refused non-whoami and non-file URLs, Host header refusal, body cap, invalid file keys, CLI usage, token never echoed
  • Live unauthenticated GET /v1/me against api.figma.com returns HTTP 401/403
  • coverage run -m pytest tests — 1145 passed, 100% on scripts/ci
  • interrogate — 100% on scripts/ci
  • After FIGMA_ACCESS_TOKEN is added, rerun whoami and --file on a Cloud Agent with a real file key
Open in Web View Automation 

cursoragent and others added 3 commits August 16, 2026 14:47
Cursor Cloud Agents cannot complete Figma MCP OAuth. Record the 401
challenge, the official Cloud-unsupported decision, and a REST
FIGMA_ACCESS_TOKEN whoami helper that never prints the secret.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Semgrep p/default flagged urllib.request.urlopen in figma_rest_auth.py
as dynamic-urllib-use-detected. Open api.figma.com over TLS with a
literal host and path, and refuse any other URL.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Cloud Agents still cannot finish Figma MCP OAuth. After whoami succeeds,
load one file at GET /v1/files/:key?depth=1 so the next action is a named
page rather than a token-only check. Pin headers to X-Figma-Token, cap
response bodies, and record APA 7th citations for the REST fallback.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
cursor Bot pushed a commit that referenced this pull request Aug 16, 2026
Absorb the #1032 security extras: allow only X-Figma-Token, cap
whoami/file bodies, cite CWE-22 and plan tokens, and keep a live
unauthenticated /v1/me accuracy check. Prefer this head over #1032.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not merge this draft in parallel with #1034.

The --file page inventory, body caps, Host refusal, plan-token doctoring, CWE-22, and live unauthenticated /v1/me check are the right security extras. They are now on #1034 (b332f91d) together with allowlisted /v1/files/{key}/nodes and /v1/images/{key}, Figma URL + node-id parse, and a separate figma_rest_file.py so whoami stays argument-free.

Keep #1028 and this PR draft. Landing vehicle is #1034. Next operator action after merge: store FIGMA_ACCESS_TOKEN, then python3 scripts/ci/figma_rest_auth.py and python3 scripts/ci/figma_rest_file.py <file-key-or-url>.

View PR

Open in Web View Automation 

Sent by Cursor Automation: Fix Issues

Comment on lines +158 to +161
connection = http.client.HTTPSConnection(
FIGMA_API_HOST,
timeout=REQUEST_TIMEOUT_SECONDS,
)
seonghobae added a commit that referenced this pull request Aug 19, 2026
Absorb the #1032 security extras: allow only X-Figma-Token, cap
whoami/file bodies, cite CWE-22 and plan tokens, and keep a live
unauthenticated /v1/me accuracy check. Prefer this head over #1032.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
seonghobae added a commit that referenced this pull request Aug 19, 2026
Absorb the #1032 security extras: allow only X-Figma-Token, cap
whoami/file bodies, cite CWE-22 and plan tokens, and keep a live
unauthenticated /v1/me accuracy check. Prefer this head over #1032.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
seonghobae added a commit that referenced this pull request Aug 19, 2026
Absorb the #1032 security extras: allow only X-Figma-Token, cap
whoami/file bodies, cite CWE-22 and plan tokens, and keep a live
unauthenticated /v1/me accuracy check. Prefer this head over #1032.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
seonghobae added a commit that referenced this pull request Aug 20, 2026
Absorb the #1032 security extras: allow only X-Figma-Token, cap
whoami/file bodies, cite CWE-22 and plan tokens, and keep a live
unauthenticated /v1/me accuracy check. Prefer this head over #1032.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
@seonghobae

Copy link
Copy Markdown
Contributor

Closing as superseded by the current-head Figma REST/auth implementation in #1146, which consolidates the file/page loading, Cloud Agent auth fallback, design fields, and branch-key contract coverage.

@seonghobae

Copy link
Copy Markdown
Contributor

Superseded by #1146.

@seonghobae seonghobae closed this Aug 20, 2026
seonghobae added a commit that referenced this pull request Aug 20, 2026
Absorb the #1032 security extras: allow only X-Figma-Token, cap
whoami/file bodies, cite CWE-22 and plan tokens, and keep a live
unauthenticated /v1/me accuracy check. Prefer this head over #1032.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants