| | @@ -1343,12 +1343,14 @@ |
| 1343 | 1343 | ** NULL pointer to stick with the IP address previously computed and |
| 1344 | 1344 | ** loaded into g.zIpAddr. |
| 1345 | 1345 | */ |
| 1346 | 1346 | static const char *cgi_accept_forwarded_for(const char *z){ |
| 1347 | 1347 | int i; |
| 1348 | | - if( fossil_strcmp(g.zIpAddr, "127.0.0.1")!=0 ) return 0; |
| 1349 | | - |
| 1348 | + if( !cgi_is_loopback(g.zIpAddr) ){ |
| 1349 | + /* Only accept X-FORWARDED-FOR if input coming from the local machine */ |
| 1350 | + return 0; |
| 1351 | + } |
| 1350 | 1352 | i = strlen(z)-1; |
| 1351 | 1353 | while( i>=0 && z[i]!=',' && !fossil_isspace(z[i]) ) i--; |
| 1352 | 1354 | return &z[++i]; |
| 1353 | 1355 | } |
| 1354 | 1356 | |
| | @@ -2031,5 +2033,13 @@ |
| 2031 | 2033 | return zSshClient; |
| 2032 | 2034 | } |
| 2033 | 2035 | } |
| 2034 | 2036 | return zDefault; |
| 2035 | 2037 | } |
| 2038 | + |
| 2039 | +/* |
| 2040 | +** Return true if information is coming from the loopback network. |
| 2041 | +*/ |
| 2042 | +int cgi_is_loopback(const char *zIpAddr){ |
| 2043 | + return fossil_strcmp(zIpAddr, "127.0.0.1")==0 || |
| 2044 | + fossil_strcmp(zIpAddr, "::ffff:127.0.0.1")==0; |
| 2045 | +} |
| 2036 | 2046 | |