-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Something about spam handling can result in hung PHP-FPM processes, which eventually take down PHP. #2065
Comments
Yeah, something's trying to hack around with forms...
|
We have also spotted in the logs something a little more alarming, as it looks as though there's malformed data in the siteId parameter, and I don't see why a front-end form would need to be posting that back to the CMS.
from
|
Yeah, something is clearly hammering your site with POST requests to Formie, and while error-handling is catching most of these (we're pretty strict about what a submission accepts, and its fields). These are direct HTTP POST requests rather than submissions from the front end, which is why they can send some messed up values our way. I'm not sure where the responsibility lies with regard to rate-limiting these sorts of things, whether that's Formie, Craft or on your server. I suppose with Formie, we can at least add some handling there. There is a "Limit Submissions" setting for forms, but that's not able to be set less than daily. It's not really designed for rate-limiting either. As for why a submission is even holding up the PHP process, that's possibly beyond be expertise without getting my hands on it. It could be the logging process that's holding things up for example. Craft holds in-memory log data until a request has ended and it's flushed to disk. It could be the case that there's just so much activity that it's always being written to, and a lock can't be gained. Not to worry about those values, that's the reason we have a And I've seen these things before, they're penetration tests, so someone or something is doing automated tests on your site for vulnerabilities. So, I suppose my recommendation is to first check if your client is doing security tests (it's happened before when clients don't give developers a heads-up first!), look into rate-checking the |
Thanks Josh... yeah, this is somewhat beyond my own knowledge and skillset tbh too, no idea how you'd rate limit anything - and I can't even get to marry up these requests with IPs to try banning them as things stand. Good to know the values in there aren't anything to worry about. We're on the latest OS everything and latest Craft everything, so hopefully they won't actually get anywhere - but just the attempts are enough to be taking PHP down at the moment, so it's still "an issue" for us :/ |
I'll do a bit of quick research (and hassle the Craft crew) if their better brains have any ideas! Might be worth pinging some people on Discord if thay've done similar things... |
In case anyone else ever gets this sort of thing: A partial solution to at least help avoid the server going down was to edit the PHP-FPM pool such that no PHP process can live longer than X amount of time, and to increase the allowed number of processes from the default.
Also of note, the server never appeared to be "stressed" and the load / memory use never seemed anything other than low. The issue was the exhausting of PHP-FPM processes and not excessive load. We are currently getting CloudFlare set up in front of the site in hopes it will detect the abuse and kerb it - though I don't like having to rely on third party services for this really. |
Describe the bug
This one took hours to track down, and I'm not sure where to look beyond that it seems to be Formie and spam submission related bug of some sort.
We have been hitting issues on a server where PHP has stopped processing all websites hosted on the server - so all websites become white-screens, unresponsive. PHP-FPM has to be restarted to restore sites on the server.
Because nothing obvious was in any logs, we used a simple PHP function to get a window into what's happening on the PHP-FPM process level:
What was showing up was numerous stuck processes where the State was
Getting request information
and never closing. They were always POST methods, and were always on the same website. Making anstrace
on any of the stuck process IDs showed it stuck on a Read operation:We then went lookiing in the logs for that website, and discovered what appear to be spam submissions throwing various errors in Formie - most obvious in the
web.log
file, but also some making it into theformie.log
file. Stuff likeInvalid numeric value
andUnable to verify your data submission
orGeneral error: 1525 Incorrect DATETIME value: '' The SQL being executed was:
orUnsupported operand types: string + int
.All forms on the site have Recaptcha integration turned on and working. The site with the problem has been working for some time (months) and other than having some Craft updates installed, nothing has changed on it. So... seems likely to be some sort of spam bot hitting the site now.
To attempt to confirm these stuck processes were actually Formie related (because you can't tell just from the PHP-FPM report) we disabled Formie and left the site running with it disabled for 30 minutes. During that time, we did not get any stuck PHP processes. After re-enabling Formie, we got another stuck process within a few minutes.
I have no idea how to help you on this, but I've attached the logs we have. I've tried to marry up the stuck-processes' timestamps to the logs (our logs are BST, so converting from UNIX to that does seem to work) - but we don't retain a record of the stuck processes because we don't know about them unless we're looking at that PHP function output from up there ^. Nothing seems to get recorded, presumably because a "stuck process" isn't an error that can be logged.
I do not know enough (even close) about the guts of PHP and Craft/Formie, but if I had to guess - it's as though something in how the spam submission is handled causes a failure to send any response to the HTTP requester - which leaves the PHP process open forever, which then causes our PHP-FPM pool to run out of available processes, which then causes all sites to become unresponsive.
formie-2024-09-12.log
web-2024-09-12.log
Steps to reproduce
See above.
Form settings
Craft CMS version
4.12.2
Plugin version
2.1.29
Multi-site?
Yes
Additional context
The text was updated successfully, but these errors were encountered: