Repository navigation
Description
NOTE: This feature request was generated by AI under my control to hopefully solve a real problem I am facing, I hope that is okay. If not please close it. Great App :)
Nextcloud (please complete the following information):
- Nextcloud-Version: 35.0.3
- Forms-Version: 5.4.2 (also main @ bb03a24, 5.5.0-dev)
Is your feature request related to a problem? Please describe.
The only public, unauthenticated endpoint in the Forms API — POST /api/v3/forms/{formId}/submissions — accepts an unlimited number of submissions from a single client, with no throttling of any kind.
For a form shared by public link, the shareHash necessarily ships to the browser, and the endpoint is #[CORS] + #[NoCSRFRequired] + #[PublicPage]. So anyone who has looked at a form page once can replay POSTs against it from a script forever, without ever loading the form again. The practical result is public contact and survey forms filling up with spam, which is the underlying complaint in #549 (open since 2020).
This is deliberately not a request for #[BruteForceProtection]. #2269 scoped that correctly to endpoints that look forms up, to prevent enumeration of IDs and hashes — and throttling respondents because a form is popular would be wrong. A valid spam submission is not a failed attempt, so the brute-force counter would never trip here anyway. What is missing is a plain per-client request limit, which core provides as AnonRateLimit.
Describe the solution you'd like
Annotate the endpoint with core's anonymous rate limiter (OCP\AppFramework\Http\Attribute\AnonRateLimit, present since NC 29), so the existing middleware throttles submissions per client IP:
use OCP\AppFramework\Http\Attribute\AnonRateLimit;
#[CORS()]
#[NoAdminRequired()]
#[NoCSRFRequired()]
#[PublicPage()]
#[AnonRateLimit(limit: 10, period: 60)]
#[ApiRoute(verb: 'POST', url: '/api/v3/forms/{formId}/submissions')]
public function newSubmission(int $formId, array $answers, string $shareHash = ''): DataResponse {The middleware answers 429 once the limit is hit, and the frontend already surfaces a failed submission, so no UI change is needed. The exact limit/period values are yours to pick — a constant is enough for a first fix; a per-form setting could follow later if there is demand.
Describe alternatives you've considered
- Captcha (reCAPTCHA / Turnstile / hCaptcha / hashcash), i.e. spam bot protection. #549: a much larger change, needs either a third-party service or a new respondent-facing step, and doesn't fit Forms' "no external dependency" character. Rate limiting is orthogonal and far cheaper — both could coexist.
- #[BruteForceProtection] on newSubmission: does not fire, as explained above.
- Client-side honeypots / time traps: trivially bypassed by anything that doesn't run the bundled JS, and third-party frontends posting to this API (a supported use case) can't be covered from the app's own UI at all.
- Proxy-level limiting (limit_req / Cloudflare): works, but pushes the fix onto every administrator and is impossible for hosted or containerised instances.
Additional context
Rate limiting is not a spam solution by itself — a low-volume, human-driven sender stays under any threshold — but it removes the bulk of automated submissions, stops one client from filling a form's results, and is a prerequisite for any future anti-spam feature.
Server-side only: no new dependency, no API contract change, no respondent-visible difference.
Activity
Chartman123 commentedon Nov 19, 2026
@David-Else thanks for bringing this up. +1 from my side :)
We need to discuss which limits should be set for the rate limiting, but 10 per minute would also be a good starting point for me.
@samin-z @susnux @Koc @AndyScherzinger what do you think?
fix(api): rate-limit the public submission endpoints
David-Else commentedon Nov 19, 2026
10 per minute sounds great. I assume a legit user would get a 429 in the submit view if they go over the limit, it would be better to give an error message in case they think the form is broken.
AndyScherzinger commentedon Nov 20, 2026
correct, the server replies with 429, but the error message has been generic. Will implement a more specific one, via #3944
fix(submit): tell respondents when they submit too often
fix(submit): tell respondents when they submit too often