-
-
Notifications
You must be signed in to change notification settings - Fork 413
Fix JSDoc comment security vulnerability: escape only necessary */ sequences #1368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FDiskas
wants to merge
11
commits into
acacode:main
Choose a base branch
from
FDiskas:copilot/fix-b818f11b-c126-4a50-8f80-a5b2a830a156
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix JSDoc comment security vulnerability: escape only necessary */ sequences #1368
FDiskas
wants to merge
11
commits into
acacode:main
from
FDiskas:copilot/fix-b818f11b-c126-4a50-8f80-a5b2a830a156
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
- Modified formatDescription() to detect already-escaped content and avoid double-escaping - Ensures */ becomes *\/ (single backslash) instead of *\\/ (double backslash) - Ensures /* becomes \/* (single backslash) instead of \\/* (double backslash) - Maintains security by still escaping dangerous JSDoc characters - All tests pass (128/128) confirming no regressions Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 37bf80a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
bugbot run |
…yEscaped check Co-authored-by: FDiskas <468006+FDiskas@users.noreply.github.com>
Updated PR |
smorimoto
approved these changes
Aug 28, 2025
bugbot run |
!_.isUndefined(field.example) && | ||
`@example ${_.isObject(field.example) ? JSON.stringify(field.example) : field.example}`, | ||
`@example ${_.isObject(field.example) ? JSON.stringify(field.example) : escapeJSDocContent(field.example)}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
vibe coded PR
closes #1321
This PR fixes a security vulnerability where unescaped characters in OpenAPI/Swagger descriptions could break generated TypeScript files or enable code injection attacks. The fix uses minimal escaping - only escaping the dangerous
*/
sequences while leaving harmless/*
sequences unescaped to reduce noise in generated documentation.Problem
Vulnerable input example:
Generated vulnerable output:
The
*/
sequence breaks out of the JSDoc comment, allowing arbitrary JavaScript code execution.Solution
The fix applies surgical escaping that only targets the dangerous pattern:
*/
sequences are escaped to*\/
(prevents comment breakout)/*
sequences remain unescaped (harmless inside comments)Safe output after fix:
Technical Details
escapeJSDocContent()
insrc/schema-parser/schema-formatters.ts
to only escape*/
route-docs.ejs
to use consistent escaping approachformatDescription()
detects already-escaped content to prevent double-escapingImpact
\/*
in docs)