5
5
</ ul >
6
6
< p > Today's services have an ever-changing architecture due to their scaling and redundancy needs. It is a mistake to think that a service will always
7
7
have the same IP address. When it does change, the hardcoded IP will have to be modified too. This will have an impact on the product development,
8
- delivery and deployment:</ p >
8
+ delivery, and deployment:</ p >
9
9
< ul >
10
10
< li > The developers will have to do a rapid fix every time this happens, instead of having an operation team change a configuration file. </ li >
11
- < li > It forces the same address to be used in every environment (dev, sys, qa, prod). </ li >
11
+ < li > It misleads to use the same address in every environment (dev, sys, qa, prod). </ li >
12
12
</ ul >
13
13
< p > Last but not least it has an effect on application security. Attackers might be able to decompile the code and thereby discover a potentially
14
- sensitive address. They can perform a Denial of Service attack on the service at this address or spoof the IP address. Such an attack is always
15
- possible, but in the case of a hardcoded IP address the fix will be much slower, which will increase an attack's impact.</ p >
14
+ sensitive address. They can perform a Denial of Service attack on the service, try to get access to the system, or try to spoof the IP address to
15
+ bypass security checks. Such attacks can always be possible, but in the case of a hardcoded IP address solving the issue will take more time, which
16
+ will increase an attack's impact.</ p >
16
17
< h2 > Ask Yourself Whether</ h2 >
17
- < p > The disclosed IP address is sensitive, eg :</ p >
18
+ < p > The disclosed IP address is sensitive, e.g. :</ p >
18
19
< ul >
19
20
< li > Can give information to an attacker about the network topology. </ li >
20
21
< li > It's a personal (assigned to an identifiable person) IP address. </ li >
21
22
</ ul >
22
23
< p > There is a risk if you answered yes to any of these questions.</ p >
23
24
< h2 > Recommended Secure Coding Practices</ h2 >
24
- < p > Don't hard-code the IP address in the source code, instead make it configurable.</ p >
25
+ < p > Don't hard-code the IP address in the source code, instead make it configurable with environment variables, configuration files, or a similar
26
+ approach. Alternatively, if confidentially is not required a domain name can be used since it allows to change the destination quickly without having
27
+ to rebuild the software.</ p >
25
28
< h2 > Sensitive Code Example</ h2 >
26
29
< pre >
27
30
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
@@ -45,6 +48,6 @@ <h2>See</h2>
45
48
< ul >
46
49
< li > < a href ="https://www.owasp.org/index.php/Top_10-2017_A3-Sensitive_Data_Exposure "> OWASP Top 10 2017 Category A3</ a > - Sensitive Data Exposure
47
50
</ li >
48
- < li > < a href ="https://www.securecoding.cert.org /confluence/x/qQCHAQ "> CERT, MSC03-J.</ a > - Never hard code sensitive information </ li >
51
+ < li > < a href ="https://wiki.sei.cmu.edu /confluence/x/OjdGBQ "> CERT, MSC03-J.</ a > - Never hard code sensitive information </ li >
49
52
</ ul >
50
53
0 commit comments