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

no-insecure-server-credentials

Do not serve plaintext gRPC on every interface

Next step

no-insecure-server-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 serve plaintext gRPC on every interface.

Why

ServerCredentials.createInsecure() turns TLS off. Every message, token and credential the server receives crosses the network in cleartext, where anything on the path can read and alter it. Bound to a wildcard address, the server is reachable from every network the host sits on.

Rule details

The rule reports server.bindAsync(address, credentials, …) (and the older server.bind) when:

  • the credentials are ServerCredentials.createInsecure() (directly, through a const, or through an imported ServerCredentials), and
  • the address proves the server listens on every interface: a wildcard host (0.0.0.0, [::], ::) or a bare port (:50051, '50051').

The address is read from literals, templates, + and consts. A host can be fixed while the port is not: in `0.0.0.0:${process.env.PORT}` the host is still known.

The rule decides from what the address itself proves:

  • Loopback (127.0.0.0/8, [::1]) and unix: sockets aren't reachable from the network. That's how the address works, not a guess.
  • A named host, or a host from the environment or configuration, stays silent. Whether it's exposed is a deployment fact the file doesn't hold, and this repository's rules don't decide by matching host names.

Incorrect

server.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), cb);
server.bindAsync(`[::]:${PORT}`, grpc.ServerCredentials.createInsecure(), cb);

Correct

server.bindAsync(
  '0.0.0.0:50051',
  grpc.ServerCredentials.createSsl(rootCerts, [{ private_key, cert_chain }]),
  cb,
);

// Plaintext behind a TLS-terminating proxy on the same host.
server.bindAsync(
  '127.0.0.1:50051',
  grpc.ServerCredentials.createInsecure(),
  cb,
);

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