Repository navigation
fix: validate API path parameters and rate-limit artist requests (#987) - #1043
Merged
DevMuhdishaq merged 1 commit intoOct 19, 2026
Merged
Conversation
…nder#987) Validate every dynamic path segment at the shared HTTP boundary, rejecting traversal, encoded separators and SQL/NoSQL payloads before a request leaves the browser. Add strict artist-id (positive integer/UUID) helpers and a 30-requests/minute guard for artist GET endpoints. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@danieloche635-bit Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #987.
Every dynamic path parameter is now validated at the shared HTTP boundary before a request leaves the browser, and artist GET endpoints are rate-limited. Traversal, encoded separators and SQL/NoSQL payloads are rejected with a
400ApiError; the artist budget returns429.Changes
src/services/requestValidation.ts(new)validateRequestPath(url)inspects the raw path beforeURLcan resolve dot segments, so/../and%2e%2e%2fare caught rather than normalised away...,%2F,%5C,%00), protocol-relative URLs (//evil.example.com), malformed percent-encoding, and characters outside a conservative token allowlist.1' OR '1'='1,1;DROP TABLE,1--,/*comment*/and{"$ne": null}.validateArtistId/assertValidArtistId: positive integer or RFC 4122 UUID (versions 1-5).validateMarketplaceId/validatePortfolioId: safe single-segment resource ids.checkRequestRateLimit: fixed-window limit of 30 GET requests/minute for theprofiles,artistsandartistendpoint families, with a retry-after message.src/services/http.tsApiError(400, 'VALIDATION_FAILED')and exhausted budgets withApiError(429, 'RATE_LIMITED')before the adapter/network is reached.ApiErrorproduced by the request guards instead of relabelling it asNETWORK_ERROR.src/services/requestValidation.test.ts— 11 tests for path safety, traversal/injection payloads, strict artist/resource ids and rate-limit windows.src/services/requestValidation.http.test.ts— 4 integration tests proving malicious requests never reach the adapter and that the 31st artist request returns429.Acceptance criteria
api/artist/[id].tsxvalidates theidparameter format — strictvalidateArtistId(positive integer or UUID) is provided and exported for the API layer400 Bad Requestwith a clear messageTesting
Pre-existing failure on
main(not introduced by this PR):src/stores/useUiStore.tshas a merge syntax error, so the oldersrc/services/http.test.tssuite cannot load. The integration test here mocks that unrelated store so it can exercise the real interceptor chain. The same pre-existing breakage also exists insrc/features/messaging/index.ts,src/components/ui/Skeleton.tsxandvite.config.ts.Security note
Client-side rate limiting is bypassable by an attacker who controls the client; it is included as defence in depth and to stop request storms. The API must also enforce per-IP/per-account limits and use parameterised queries.