Skip to main content
Skip to Content
interlace
SecurityPlugin: grpc-securityRules

no-insecure-channel-credentials

Do not send credentials over a plaintext gRPC channel

Next step

no-insecure-channel-credentials ships in eslint-plugin-grpc-security, with 6 of its 6 rules in the recommended preset.

Install
npm install -D eslint-plugin-grpc-security
eslint.config.js
import { configs } from 'eslint-plugin-grpc-security';

export default [configs.recommended];

Plugin pagenpmSource on GitHub

Do not send credentials over a plaintext gRPC channel.

Why

credentials.createInsecure() builds a channel with no TLS. A call on it that carries a bearer token, a session cookie or an API key sends that secret in cleartext to everything on the network path. Anyone who can read the traffic can replay the token.

Rule details

The rule decides from the credential flow, never from the target's host name. It reports the createInsecure() call when the same file shows all of:

  1. A client built on it: const client = new Client(target, credentials.createInsecure()), including any generated service client, a const holding the credentials, or an imported credentials.
  2. Metadata carrying a credential: const md = new Metadata() filled with md.add / md.set under authorization, proxy-authorization, cookie or x-api-key (any case), or with a value that starts with RFC 6750's Bearer scheme followed by a space.
  3. A call on that client that passes the metadata, in any argument position (unary, streaming, makeUnaryRequest).

A plaintext channel that carries no secret (a sidecar, a health check) isn't reported. The header set is the definition of a credential header (RFC 9110, RFC 6265), and the Metadata API is what anchors it.

Incorrect

const client = new pkg.Accounts(target, grpc.credentials.createInsecure());
const md = new grpc.Metadata();
md.add('authorization', `Bearer ${token}`);
client.GetAccount({ id }, md, callback);

Correct

const client = new pkg.Accounts(target, grpc.credentials.createSsl());
const md = new grpc.Metadata();
md.add('authorization', `Bearer ${token}`);
client.GetAccount({ id }, md, callback);

Limits

  • Call credentials attached through combineChannelCredentials or a call option aren't followed: gRPC refuses to compose them with insecure channel credentials.
  • Metadata built in another file or by a helper isn't followed.

Further reading

Use this rule

npm install -D eslint-plugin-grpc-security
eslint.config.js
import grpcSecurity from 'eslint-plugin-grpc-security';export default [  {    plugins: { 'grpc-security': grpcSecurity },    rules: {      'grpc-security/no-insecure-channel-credentials': 'error'    },  },];
npm install -D oxlint-plugin-grpc-security
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-grpc-security"],  "rules": {    "grpc-security/no-insecure-channel-credentials": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-grpc-security'],    rules: {      'grpc-security/no-insecure-channel-credentials': '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.