Restrict /api/pr file paths to packages/cdn/**
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 3
- Avg merge
- 7h 28m
- Merged PRs (30d)
- 5
Description
Summary
POST /api/pr will create a GitHub PR for any path the caller sends. The only real control is whether that GitHub token can push yearn/cms.
What happens
packages/app/src/server/pr.ts takes path / changes[].path from the JSON body and writes blobs + a tree with those paths. There is no allowlist. A token with write access could therefore propose changes under .github/** or other non-CDN paths, not only vault/strategy JSON.
Unauthenticated requests fail before any GitHub ref is created (token required). Random public_repo users still cannot push yearn/cms. This is defense in depth for stolen or overly-broad collaborator tokens (see the OAuth token-in-URL issue).
Suggested fix
- Accept only paths under
packages/cdn/. - Reject
.github/**, workflow files, and anything outside the metadata trees. - After the OAuth session moves into a cookie, add CSRF protection (
SameSite+ a CSRF token) on this route.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/app/src/server/pr.ts and trace how path and changes[].path from POST /api/pr are used to build GitHub blobs and trees. Restrict accepted paths to packages/cdn/**, reject .github and other paths, and verify requests outside the metadata trees fail; treat the later cookie-based CSRF protection as separate follow-up work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, typescript
- Domain
- api, backend, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100