Skip to content

fix: api endpoints for image upload, share creation,... in [[id]].js - #254

Open
anupamme wants to merge 1 commit into
ThisIs-Developer:mainfrom
anupamme:fix-repo-markdown-viewer-image-upload-rate-limit
Open

fix: api endpoints for image upload, share creation,... in [[id]].js#254
anupamme wants to merge 1 commit into
ThisIs-Developer:mainfrom
anupamme:fix-repo-markdown-viewer-image-upload-rate-limit

Conversation

@anupamme

Copy link
Copy Markdown

Summary

Fix high severity security issue in functions/api/image/[[id]].js.

Vulnerability

Field Value
ID V-001
Severity HIGH
Scanner multi_agent_ai
Rule V-001
File functions/api/image/[[id]].js:1
Assessment Likely exploitable

Description: API endpoints for image upload, share creation, and live room WebSocket operations lack rate limiting controls. An attacker can send unlimited requests, exhausting Cloudflare Worker CPU time limits (50ms per request), KV storage quotas, or causing service degradation for legitimate users.

Evidence

Exploitation scenario: Attacker sends automated high-volume requests to /api/image/ or /api/share/ endpoints.

Scanner confirmation: multi_agent_ai rule V-001 flagged this pattern.

Production code: This file is in the production codebase, not test-only code.

Threat Model Context

This API endpoint appears to be publicly accessible. This is a private Node.js application (not published to npm). Vulnerabilities affect this application's own runtime only.

Changes

  • functions/api/image/[[id]].js

Behavior Preservation

The change is scoped to 1 file on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.


Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@anupamme is attempting to deploy a commit to the BS Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markdown-viwer Ready Ready Preview Aug 29, 2026 11:51am

@ThisIs-Developer

Copy link
Copy Markdown
Owner

@anupamme Thanks for working on this security improvement.

The intent is correct, but I don’t think this implementation is safe to merge yet.

The main concern is that Workers KV is not suitable for a high-frequency per-IP counter. Rapid consecutive uploads can cause multiple writes to the same key, which may fail or produce inaccurate counts because the read-update-write flow is not atomic.

Also, the current 60-second TTL logic does not behave like a true “20 uploads per minute” limit. Since the TTL is refreshed after every upload, even a user uploading slowly could eventually hit the limit.

So for now, I’m not merging this PR. Let’s both look for a better rate-limiting approach and work on a safer solution.

Thank you again for pointing out this important security issue and helping improve Markdown Viewer.

Repository owner locked as too heated and limited conversation to collaborators Sep 3, 2026
@ThisIs-Developer ThisIs-Developer added help wanted Extra attention is needed question Further information is requested labels Sep 3, 2026
@ThisIs-Developer ThisIs-Developer self-assigned this Sep 3, 2026
@ThisIs-Developer
ThisIs-Developer requested a lite review from Copilot September 3, 2026 16:50
Repository owner unlocked this conversation Sep 3, 2026
@ThisIs-Developer
ThisIs-Developer requested a balanced review from Copilot and removed request for Copilot September 3, 2026 20:16

This comment was marked as low quality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants