Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/api/challenges/challenges.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export class ChallengesService {
) {}

async getChallenge(challengeId: string) {
const requestUrl = `${TC_API_BASE}/challenges/${challengeId}`;
// Use the URL constructor to avoid path traversal/SSRF risks.
const baseUrl = TC_API_BASE.endsWith('/') ? TC_API_BASE.slice(0, -1) : TC_API_BASE;
const requestUrl = new URL(`/challenges/${challengeId}`, baseUrl).toString();

Choose a reason for hiding this comment

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

[❗❗ security]
Ensure that challengeId is a valid UUID before constructing the URL. Although the controller checks this, re-validating here adds an extra layer of security against SSRF attacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vas3a see budy's comment :)


try {
const challenge = await this.m2MService.m2mFetch<Challenge>(requestUrl);
Expand Down