Difference between revisions of "Trusting self-reported IP address"

From OWASP
Jump to: navigation, search
 
Line 1: Line 1:
 
  
 
{{Template:SecureSoftware}}
 
{{Template:SecureSoftware}}
Line 45: Line 44:
 
In C/C++:
 
In C/C++:
  
 +
<pre>
 
sd = socket(AF_INET, SOCK_DGRAM, 0);
 
sd = socket(AF_INET, SOCK_DGRAM, 0);
 
serv.sin_family = AF_INET;
 
serv.sin_family = AF_INET;
Line 57: Line 57:
 
               (struct sockaddr *) & cli, &clilen);
 
               (struct sockaddr *) & cli, &clilen);
 
}
 
}
 +
</pre>
 +
 
In Java:
 
In Java:
  
 +
<pre>
 
while(true) {
 
while(true) {
 
   DatagramPacket rp=new DatagramPacket(rData,rData.length);
 
   DatagramPacket rp=new DatagramPacket(rData,rData.length);
Line 74: Line 77:
 
   }   
 
   }   
 
}
 
}
 +
</pre>
 +
 
==Related problems ==
 
==Related problems ==
  
* Trusting self-reported DNS name
+
* [[Trusting self-reported DNS name]]
  
* Using the referer field for authentication
+
* [[Using the referer field for authentication]]
  
 
==Categories ==
 
==Categories ==

Revision as of 11:11, 16 April 2006


Overview

The use of IP addresses as authentication is flawed and can easily be spoofed by malicious users.

Consequences

  • Authentication: Malicious users can fake authentication information, impersonating any IP address

Exposure period

  • Design: Authentication methods are generally chosen during the design phase of development.

Platform

  • Languages: All
  • Operating platforms: All

Required resources

Any

Severity

High

Likelihood of exploit

High

Avoidance and mitigation

  • Design: Use other means of identity verification that cannot be simply spoofed.

Discussion

As IP addresses can be easily spoofed, they do not constitute a valid authentication mechanism. Alternate methods should be used if significant authentication is necessary.

Examples

In C/C++:

sd = socket(AF_INET, SOCK_DGRAM, 0);
serv.sin_family = AF_INET;
serv.sin_addr.s_addr = htonl(INADDR_ANY);
servr.sin_port = htons(1008);
bind(sd, (struct sockaddr *) & serv, sizeof(serv));
while (1) {
  memset(msg, 0x0, MAX_MSG);
  clilen = sizeof(cli);
  if (inet_ntoa(cli.sin_addr)==...)
  n = recvfrom(sd, msg, MAX_MSG, 0,
              (struct sockaddr *) & cli, &clilen);
}

In Java:

while(true) {
  DatagramPacket rp=new DatagramPacket(rData,rData.length);
         
  outSock.receive(rp);
  String in = new String(p.getData(),0, rp.getLength());
  InetAddress IPAddress = rp.getAddress();
  int port = rp.getPort();
          
  if ((rp.getAddress()==...) && (in==...)){
    out = secret.getBytes();
    DatagramPacket sp =new DatagramPacket(out,out.length,
      IPAddress, port);
    outSock.send(sp);
  }  
}

Related problems

Categories