antonioribeiro / antonioribeiro/firewall

Validate X-Forwarded-For attacks to prevent error, also could add attackers to firewall

Open
#175 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1.4k
Forks
174
PR merge metrics
No merged PRs in 30d

Description

I get a lot of attacks using the X-Forwarded-For header, i.e.:
`
}__test|O:21:"JDatabaseDriverMysqli":3:{s:2:"fc";O:17:"JSimplepieFactory":0:{}s:21:"\0\0\0disconnectHandlers";a:1:{i:0;a:2:{i:0;O:9:"SimplePie":5:{s:8:"sanitize";O:20:"JDatabaseDriverMysql":0:{}s:8:"feed_url";s:56:"die(md5(DIRECTORY_SEPARATOR));JFactory::getConfig();exit";s:19:"cache_name_function";s:6:"assert";s:5:"cache";b:1;s:11:"cache_class";O:20:"JDatabaseDriverMysql":0:{}}i:1;s:4:"init";}}s:13:"\0\0\0connection";b:1;}�
`

This produces a 500 error in AttackBlocker.php on line 450:
`gethostbyaddr(): Address is not a valid IPv4 or IPv6 address`

Can we handle the error to avoid the 500? Also, could we add an option to firewall these attackers? Although, given the fake X-Forwarded-For we would have to use a different method of determining their IP.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at AttackBlocker.php line 450 and inspect the gethostbyaddr() call that receives the malformed X-Forwarded-For value. Reproduce the request to confirm the 500 error, then determine how invalid forwarded addresses should be handled and how attacker blocking should identify a trustworthy IP. Done means the malformed header no longer causes a 500 and the intended firewall behavior is covered by the project’s tests, if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.