Skip to content

fix(svg): sanitize border and labelColor attributes to prevent XSS#6227

Merged
JhaSourav07 merged 2 commits into
JhaSourav07:mainfrom
diksha78dev:fix/issue-6159
Jun 21, 2026
Merged

fix(svg): sanitize border and labelColor attributes to prevent XSS#6227
JhaSourav07 merged 2 commits into
JhaSourav07:mainfrom
diksha78dev:fix/issue-6159

Conversation

@diksha78dev

Copy link
Copy Markdown
Contributor

Description

Fixes #6159

This PR addresses an SVG injection (XSS) vulnerability by applying strict hex color sanitization to the labelColor and border query parameters in the SVG generator. These parameters were previously interpolated directly into the SVG template without validation.

  • Wrapped params.labelColor with sanitizeHexColor using the theme's base color as a secure fallback.
  • Wrapped all params.border occurrences with sanitizeHexColor using #000000 as a secure fallback.
  • Ensures malformed colors or malicious HTML payloads fall back gracefully without breaking the SVG or allowing script execution.

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A — Security fix. No visual changes under normal usage. Malformed or malicious inputs now gracefully fallback to safe default colors.

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jun 21, 2026
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Jun 21, 2026
@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 3697.00 KB 3697.00 KB 0 B
Total CSS 296.58 KB 296.58 KB 0 B

@Aamod-Dev Aamod-Dev added GSSoC 2026 mentor:Aamod007 level:critical High-priority or mission-critical contributions affecting core systems, security, or infrastructure quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. security bug Something isn't working labels Jun 21, 2026

@Aamod-Dev Aamod-Dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for finding and patching this! Unsanitized interpolation of query parameters into SVGs is a classic vector for XSS. Applying sanitizeHexColor to border and labelColor in lib/svg/generator.ts effectively closes this vulnerability. Approved!

@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 21, 2026
@JhaSourav07 JhaSourav07 merged commit d7b24d4 into JhaSourav07:main Jun 21, 2026
11 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @diksha78dev! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 21, 2026
@github-actions github-actions Bot added the type:bug Something isn't working as expected label Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:critical High-priority or mission-critical contributions affecting core systems, security, or infrastructure mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. security type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(svg): unsanitized border in SVG stroke attribute (MEDIUM)

3 participants