Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate_rules.php: why forbid curl_exec and curl_multi_exec? #485

Open
bohwaz opened this issue Mar 23, 2024 · 9 comments
Open

generate_rules.php: why forbid curl_exec and curl_multi_exec? #485

bohwaz opened this issue Mar 23, 2024 · 9 comments
Labels

Comments

@bohwaz
Copy link
Contributor

bohwaz commented Mar 23, 2024

These functions cannot execute any code, they can just launch HTTP requests.

@jvoisin
Copy link
Owner

jvoisin commented Mar 24, 2024

curl_exec can be used with file:// to read local files, as well as other not-that-know nasty tricks to perform interesting things™

@bohwaz
Copy link
Contributor Author

bohwaz commented Mar 24, 2024

Ah yes forgot about that! I suggested a PR to protect against this. This shouldn't break much existing code as I can't see a lot of use.

@jvoisin
Copy link
Owner

jvoisin commented Mar 24, 2024

Unfortunately, curl supports a lot of protocols, I don't think a deny-list is the way to go. Moreover, another stupid vector would be SSRF as well.

@bohwaz
Copy link
Contributor Author

bohwaz commented Mar 24, 2024

Yes but only file:// allows to fetch local files :)

The best would be the ability for PHP to force the allowed CURL protocols using a ini setting.

@jvoisin
Copy link
Owner

jvoisin commented Mar 24, 2024

Not really no: having an attacker able to control the parameter of curl_exec effectively results in a port-scanner/proxy, even when http/https is the only protocol enabled.

@bohwaz
Copy link
Contributor Author

bohwaz commented Mar 25, 2024

As with most of snuffleupagus features and rules, it will not help against all attacks, but this will still mitigate one class of attack, still useful IMHO.

@jvoisin
Copy link
Owner

jvoisin commented Mar 25, 2024

Moving from "curl_exec can't be user-controlled easily" to "curl_exec can't use file://" does significatively reduce the amount of attacks that is defended against though.

@bohwaz
Copy link
Contributor Author

bohwaz commented Mar 25, 2024

Yes, but when you need to use curl, you don't have a choice :)

@jvoisin
Copy link
Owner

jvoisin commented Mar 26, 2024

Then it would make sense to comment the rule, and add a new more tailored one. The default rules are meant as a starting point/example, not as a comprehensive solution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants