Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V5331. Hardcoded IP addresses are...
menu mobile close menu
Additional information
toggle menu Contents

V5331. Hardcoded IP addresses are not secure.

Apr 28 2025

Using hardcoded IP addresses in code can reveal network details, making it easier for an attacker to analyze the application infrastructure.

For example, directly specifying the SSH server address creates a potential vulnerability:

public static final String SSH_SERVER_ADDRESS = "117.107.58.59";

void connect() {
    Socket socket = new Socket(SSH_SERVER_ADDRESS, 22);
    // ....
}

When this code gets into the public domain or into the hands of an attacker, the internal infrastructure is no longer confidential.

This solution also binds the application to a specific environment, making it more difficult to configure and update.

Use external sources for secure storage of confidential parameters. For example, environment variables:

public static final String SSH_SERVER_ADDRESS =
    System.getenv("MYAPP.SSH_SERVER_ADDRESS");

void connect() {
    Socket socket = new Socket(SSH_SERVER_ADDRESS, 22);
    // ....
}

This diagnostic is classified as:

close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I want to join the test
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam