Skip to main content
LowContentOWASP A05:2021CWE-200

How to fix: Hard-coded IP addresses in source

Private or public IP addresses are hard-coded in the client-side source, potentially revealing internal infrastructure.

Why it matters

Hard-coded private IP addresses reveal internal network topology. Hard-coded public IPs reveal backend server locations that may be protected only by hostname-based firewall rules, and prevent easy infrastructure migration.

IP addresses should be read from configuration, not embedded in source code.

How to fix it

  1. 1Replace hard-coded IPs with hostnames resolved from environment variables
  2. 2Ensure private/internal IP addresses are never sent to client-side code
  3. 3For internal service communication, use service discovery or environment variables

Code examples

Move hardcoded IPs to environment variables

JavaScript
// Unsafe: hardcoded IP in source code
const DB_HOST = '10.0.0.5';
const REDIS_HOST = '192.168.1.20';

// Safe: read from environment
const DB_HOST = process.env.DB_HOST;
const REDIS_HOST = process.env.REDIS_HOST;

References

Detected automatically by VulnRadar. The check id is hardcoded-ip-addresses, stable across every scan so you can filter or diff on it.

See every content check

Questions

How severe is Hard-coded IP addresses in source?
VulnRadar rates this low severity in the content category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id hardcoded-ip-addresses, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Hard-coded IP addresses in source map to?
It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for hard-coded ip addresses in source

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Hard-coded IP addresses in source | VulnRadar