From d38793883f12e43c29d2ac5f87f51f7866527ee8 Mon Sep 17 00:00:00 2001 From: Christopher Hicks Date: Sun, 30 Aug 2026 14:23:26 -0700 Subject: [PATCH 1/2] fix(security): sanitize color params and escape title to stop SVG/HTML injection The /graph endpoint interpolated custom_title and all *_color query params directly into the generated SVG (a ', + point: 'red', + title_color: 'red} ', + } as any); + + expect(utils.queryOptions().colors).toEqual(themes.default); + }); + + it('accepts valid hex color params unchanged', () => { + const utils = new Utilities({ + username: 'githubusername', + color: 'abc123', + bg_color: 'fff', + } as any); + + const { colors } = utils.queryOptions(); + expect(colors.color).toBe('abc123'); + expect(colors.bgColor).toBe('fff'); + }); + }); + + describe('Title escaping', () => { + it('escapes HTML in custom_title so it cannot break out of the SVG', async () => { + const utils = new Utilities({ + username: 'githubusername', + custom_title: '', + } as any); + + const { finalGraph } = await utils.buildGraph({ + name: 'someone', + contributions: [{ contributionCount: 1, date: '1' }], + }); + + expect(finalGraph).not.toContain('