no-unbounded-message-size
Keep gRPC message size limits bounded
Next step
no-unbounded-message-size ships in eslint-plugin-grpc-security, with 4 of its 4 rules in the recommended preset.
npm install -D eslint-plugin-grpc-securityimport { configs } from 'eslint-plugin-grpc-security';
export default [configs.recommended];
Keep gRPC message size limits bounded.
- CWE: CWE-770 — Allocation of Resources Without Limits or Throttling
- OWASP: A04:2021 — Insecure Design
- CVSS: 7.5 (High)
- Recommended:
error
Why
grpc.max_receive_message_length and grpc.max_send_message_length cap how large one gRPC message may be, and gRPC defaults the receive cap to 4 MiB. With the cap at -1 (no limit) or at gigabytes, one client request can make the process buffer that much before any handler code runs. A single caller can then exhaust the server's memory.
Rule details
The rule reports either option, on a server, a client or a channel, when its value is -1 (or any negative number) or above 100 MiB. It reads object literals (including computed literal keys) and assignments such as options['grpc.max_receive_message_length'] = -1.
The value is evaluated, never guessed. The rule reads number literals, unary - and +, * + - / ** <<, const bindings, Infinity and Number.MAX_SAFE_INTEGER / MAX_VALUE / POSITIVE_INFINITY. A value from configuration or a call can't be judged from the source, so the rule stays silent on it.
The keys are gRPC's own channel-argument names, so matching them exactly is structure, not a guess about naming.
Incorrect
const server = new grpc.Server({ 'grpc.max_receive_message_length': -1 });
const client = new pkg.Uploads(target, creds, {
'grpc.max_send_message_length': 1024 * 1024 * 1024,
});Correct
const server = new grpc.Server({
'grpc.max_receive_message_length': 16 * 1024 * 1024,
});To move large payloads, stream them in chunks instead of raising the cap.
Further reading
Use this rule
npm install -D eslint-plugin-grpc-securityimport grpcSecurity from 'eslint-plugin-grpc-security';export default [ { plugins: { 'grpc-security': grpcSecurity }, rules: { 'grpc-security/no-unbounded-message-size': 'error' }, },];npm install -D oxlint-plugin-grpc-security{ "jsPlugins": ["oxlint-plugin-grpc-security"], "rules": { "grpc-security/no-unbounded-message-size": "error" }}import { defineConfig } from 'vite-plus';export default defineConfig({ lint: { jsPlugins: ['oxlint-plugin-grpc-security'], rules: { 'grpc-security/no-unbounded-message-size': 'error', }, },});oxlint-plugin-grpc-security re-exports eslint-plugin-grpc-security/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.
Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.