PolicyEngine / PolicyEngine/policyengine-app-v2

Security: escape user-controlled path in OG HTML handlers

Open
#948 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
1
Forks
3
Avg merge
1d 50m
Merged PRs (30d)
39

Description

Summary

The OG HTML endpoints in policyengine-app-v2 are vulnerable to reflected XSS via the path query parameter.

Severity

High

Impact

A crafted query string can break out of attribute context and return executable HTML/JS in the OG response.

Affected code

  • app/api/og.ts:79-107,237-241
  • mirrored copy in policyengine-app-v2-blog/app/api/og.ts:74-102,232-236

Details

pathname from url.searchParams.get("path") is concatenated into fullUrl and then injected into og:url, canonical-style links, and <a href> attributes without escaping.

Expected behavior

User-controlled URL parts should be escaped for HTML attribute context or encoded before interpolation.

Suggested remediation

  • Escape url before writing it into HTML
  • Prefer constructing safe URLs and serializing with an attribute escaper
  • Add regression tests with quote-breaking payloads

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the affected ranges in app/api/og.ts and the mirrored policyengine-app-v2-blog/app/api/og.ts, tracing how the path query parameter reaches the generated attributes. Add regression coverage using quote-breaking payloads, then verify that every user-controlled URL value is safe in HTML attribute context in both handlers.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.