swagger-api / swagger-api/swagger-ui

Make it more difficult to accidentally write an unsanitized URL to the DOM

Open
#5,402 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: security type: housekeeping
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Is your feature request related to a problem?

Aside from constant vigilance, there's nothing keeping us from accidentally introducing a URL-related XSS bug in a pull request.

Describe the solution you'd like
  1. instead of pulling in sanitizeUrl everywhere we need it, modify our Link component to sanitize any href (and maybe some other attributes?) it receives
  2. add a linter rule that requires users to use Link instead of bare anchor elements

and there you have it! sanitized URLs become the path of least resistance in new code!

Additional context

Occurred to me while reviewing a PR https://github.com/swagger-api/swagger-ui/pull/5395/files#diff-2d31cb4d375fa2c819408dbbaf4fac66R3

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 reviewing the linked pull request and the existing sanitizeUrl and Link usage described in the issue. Define the scope of URL-bearing attributes and the linter behavior; the work is done when Link sanitizes the intended inputs and the rule consistently discourages bare anchors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, security, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.