Skip to content

Secure GET /submissions/{id} with token validation#37

Merged
SebastienTainon merged 3 commits into
masterfrom
secure-get-submission
May 29, 2026
Merged

Secure GET /submissions/{id} with token validation#37
SebastienTainon merged 3 commits into
masterfrom
secure-get-submission

Conversation

@SebastienTainon

Copy link
Copy Markdown
Contributor

No description provided.

@SebastienTainon SebastienTainon requested a review from smadbe May 13, 2026 08:38
@SebastienTainon SebastienTainon force-pushed the secure-get-submission branch from 304ae62 to af3c4aa Compare May 13, 2026 09:11
@SebastienTainon SebastienTainon force-pushed the secure-get-submission branch from af3c4aa to 84b3a4d Compare May 13, 2026 10:36
Comment thread src/submissions.ts
Comment on lines +49 to +52
const booleanFlag = pipe(
D.union(D.boolean, D.string),
D.map(v => v !== null && v !== undefined),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

v !== null && v !== undefined : It cannot be undefined/null as you only allow boolean and string.

=>

  • ?longPolling=false ⇒ evaluated as true.
  • Missing ⇒ undefined (not false)

Comment thread src/submissions.ts
Comment on lines 352 to +357
const submission = await findSubmissionById(submissionId);
if (null === submission) {
return null;
}

await checkAuthorizedToGetSubmission(submissionQueryParameters, submission);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You do some operation before check auth. So:

  • DoS is easier (easy to make you do many DB request for nothing)
  • you can use this service as an oracle to know whether a id exists, even without valid auth
    (I may be wrong)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes but whether the auth is valid depends on if the submission parameters match the token parameters, and to check this I need to fetch the submission first.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That means a bot can easily DDoS the endpoint. First verifying the token validity (so signature + dates) would make sense.

Comment thread src/submissions.ts Outdated

// Check task token data match submission data
if (submission.idTask !== taskTokenData.taskId) {
throw new InvalidInputError(`Task id mismatch between submission data and provided task id from the token: ${taskTokenData.taskId}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it looks like more like a 403/401 than an input error

Comment thread features/get_submission.feature Outdated
"""
{
"error": "Incorrect input arguments.",
"message": "Error: Missing token or platform POST variable"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

POST variable? on a GET srv

@SebastienTainon SebastienTainon merged commit 7a164e7 into master May 29, 2026
3 checks passed
@SebastienTainon SebastienTainon deleted the secure-get-submission branch May 29, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants