Skip to content

Commit 6f3ce02

Browse files
Potential fix for code scanning alert no. 2: Server-side request forgery
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent ab95754 commit 6f3ce02

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/api/challenges/challenges.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export class ChallengesService {
6161
) {}
6262

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

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

0 commit comments

Comments
 (0)