akash-network / akash-network/console

perf(api): add body size validation to notification/alert proxy routes

Open Beginner friendly
#2,585 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance tech-debt
Dominant language
TypeScript
Stars
264
Forks
94
Avg merge
18h 49m
Merged PRs (30d)
297

Description

Problem

The notification and alert proxy routes forward request bodies as-is to the downstream notifications service without any size validation.

// proxy.route.ts
await req.text()  // reads full body without size check, then forwards it

These routes accept POST, PATCH, and DELETE methods and proxy the full body content.

Affected Routes

  • POST /v1/notification-channels/*
  • PATCH /v1/notification-channels/*
  • DELETE /v1/notification-channels/*
  • POST /v1/alerts
  • PATCH /v1/alerts
  • DELETE /v1/alerts

Suggested Fix

Add body size validation before proxying:

const body = await req.text();
if (body.length > MAX_PROXY_BODY_SIZE) {
  return c.json({ error: "Request body too large" }, 413);
}

Or apply the global body limit middleware (from #2582) which would cover these routes automatically.

Files

  • apps/api/src/notifications/routes/proxy.route.ts

Context

Part of the API event loop performance audit.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/api/src/notifications/routes/proxy.route.ts and inspect how the notification-channel and alert proxy routes read and forward request bodies. Compare the proposed local check with the global body limit middleware from #2582. Done means the affected POST, PATCH, and DELETE routes reject oversized bodies with status 413 while continuing to proxy acceptable bodies.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.