Skip to content

Commit ad6ba28

Browse files
authored
fix(validation): add max-length and regex validation to org parameter in streakParamsSchema (JhaSourav07#1664)
## Description The `org` parameter in `streakParamsSchema` at `lib/validations.ts:186` had zero validation (`org: z.string().optional()`) -- no min, no max, no regex. Any arbitrary string of any length was accepted and directly interpolated into GitHub REST API URL paths. This enabled path-traversal attacks against the GitHub API, bypassing the strict validation enforced on the `user` parameter. Fixes JhaSourav07#1366: - SSRF: path-traversal sequences in org parameter could reach unintended GitHub API endpoints - Injection: unvalidated string length could create enormous URL strings stressing the server - Inconsistency: org had no validation while user on the same schema had strict regex + max(39) ## Pillar - [ ] Pillar 1 - New Theme Design - [ ] Pillar 2 - Geometric SVG Improvement - [ ] Pillar 3 - Timezone Logic Optimization - [x] Other (Bug fix, refactoring, docs) ## Checklist before requesting a review: - [x] I have read the CONTRIBUTING.md file. - [x] I have tested these changes locally. - [x] I have run npm run format and npm run lint locally and resolved all errors. - [x] My commits follow the Conventional Commits format.
2 parents 7a22134 + b0a0ff9 commit ad6ba28

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/validations.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,13 @@ export const streakParamsSchema = z.object({
183183
grace: z.string().optional().transform(toGraceValue).default(1),
184184
mode: z.enum(['commits', 'loc']).catch('commits').default('commits'),
185185
repo: z.string().optional(),
186-
org: z.string().optional(),
186+
org: z
187+
.string()
188+
.max(39, { message: 'Organization name cannot exceed 39 characters' })
189+
.regex(GITHUB_USERNAME_REGEX, {
190+
message: 'Invalid organization name format',
191+
})
192+
.optional(),
187193
labels: z.string().optional().transform(toBooleanFlag),
188194
labelColor: z
189195
.string()

0 commit comments

Comments
 (0)