Skip to content

Commit ff25ba9

Browse files
committed
Validate challengeId inside getChallenge method
1 parent 6d14756 commit ff25ba9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/api/challenges/challenges.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
uniqBy,
99
} from 'lodash';
1010
import { ConflictException, Injectable } from '@nestjs/common';
11+
import { isUUID } from 'class-validator';
1112
import { ENV_CONFIG } from 'src/config';
1213
import { Logger } from 'src/shared/global';
1314
import {
@@ -61,6 +62,10 @@ export class ChallengesService {
6162
) {}
6263

6364
async getChallenge(challengeId: string) {
65+
if (!isUUID(challengeId)) {
66+
throw new BadRequestException('Invalid challengeId provided! Uuid expected!');
67+
}
68+
6469
// Use the URL constructor to avoid path traversal/SSRF risks.
6570
const baseUrl = TC_API_BASE.endsWith('/') ? TC_API_BASE.slice(0, -1) : TC_API_BASE;
6671
const requestUrl = new URL(`/challenges/${challengeId}`, baseUrl).toString();

0 commit comments

Comments
 (0)