Skip to content

Security/Enchance: Implement CSP Headers & SVG Injection Prevention #84

@vib3withsimran

Description

@vib3withsimran

Type: security
Level: advanced
Labels: gssoc26, type:security, hardening

Description:

The app currently lacks content security policy and strict SVG validation, leaving it vulnerable to XSS attacks through user input in profiles.

Security Risks

  1. SVG Injection - Usernames/bios with special characters could break SVG structure
  2. No CSP Headers - Missing Content-Security-Policy allows inline scripts
  3. Insufficient Escaping - Some user data may not be fully sanitized

What's Needed

  1. Add CSP Headers (profile.route.js)

  2. Enhance escapeXml() Function

  • Ensure ALL special XML chars are escaped: & < > " '
  • Test with attack vectors like: <script>, javascript:, on*=
  1. Input Validation
  • Validate usernames against strict regex (already done)
  • Validate platform handles (LeetCode, Codeforces, CodeChef)
  • Reject input with suspicious patterns
  1. Security Tests
  • Test with XSS payloads: "><script>alert(1)</script>, etc.
  • Verify CSP headers are set on all responses
  • Check SVG renders safely with malicious input

Files to Modify

  • src/routes/profile.route.js (add CSP middleware)
  • src/renderers/svg.renderer.js (enhance escapeXml)
  • src/services/github.service.js (validate data)

Kindly assign this issue to me under gssoc26!
Thankyou

Acceptance Criteria

✅ CSP headers present on all profile responses
✅ XSS payloads are escaped and render as text, not code
✅ Security audit passes (use OWASP guidelines)
✅ Unit tests verify injection attempts fail safely

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions