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.
npm install -D eslint-plugin-grpc-securityimport { configs } from 'eslint-plugin-grpc-security';
export default [configs.recommended];
Do not send credentials over a plaintext gRPC channel.
- CWE: CWE-319 — Cleartext Transmission of Sensitive Information
- OWASP: A02:2021 — Cryptographic Failures
- CVSS: 7.4 (High)
- Recommended:
error
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:
- A client built on it:
const client = new Client(target, credentials.createInsecure()), including any generated service client, aconstholding the credentials, or an importedcredentials. - Metadata carrying a credential:
const md = new Metadata()filled withmd.add/md.setunderauthorization,proxy-authorization,cookieorx-api-key(any case), or with a value that starts with RFC 6750'sBearerscheme followed by a space. - 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
combineChannelCredentialsor 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-securityimport 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{ "jsPlugins": ["oxlint-plugin-grpc-security"], "rules": { "grpc-security/no-insecure-channel-credentials": "error" }}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.