ModSecurity keeps blocking my checkout and I'm losing sales

sarah_2891

New Member
Messages
50
Reaction score
0
Location
Denver, CO

So my host turned on ModSecurity rules a couple weeks ago, "for our protection," and since then I've had at least 6 customers email me saying they got a 403 error at checkout. Six that bothered to email. Who knows how many just bounced.

The rule ID it's throwing is some generic SQL injection thing that's triggered by the order notes field. Someone types a note with an apostrophe or the word "select" in it and boom, blocked. My host says they can whitelist rules per domain but they want me to document which rule IDs I need excluded, which means I have to reproduce the errors myself and dig through logs like a detective.

Anyway I've got the rule disabled for now and checkout works, but I feel naked without the WAF. Is there a sane middle ground here or is this just the tax you pay for having protection that actually protects? Half tempted to go back to nothing and just lean on fail2ban.

For reference this is the security board I've been lurking on for the log reading tips:
https://websiteforums.info/forums/website-security.19/

Curious what rules you all exclude and whether your host gives you any pushback about it.

greg_ohio

New Member
Messages
71
Reaction score
0
Location
Columbus, OH

Bhai I feel you, had almost the same drama last year. My host's WAF kept flagging my contact form whenever someone typed an apostrophe or the word "select" in the message box. Lost a bunch of signups before I even noticed, same as you. Nobody emails, they just leave.

But honestly going back to nothing is worse than the 403s. fail2ban only really catches brute force on SSH and login attempts, it won't do jack for SQLi or XSS hitting your checkout. So you'd be trading an annoying headache for an actual hole.

What worked for me, and I'm not a dev so take it with salt, was asking the host for the audit log export instead of the live viewer. Mine sent a CSV with the rule ID plus the exact parameter that tripped it. Turned out only 2 rules were the problem, so I got those whitelisted for the /checkout path only, not the whole domain. Narrower scope = less naked feeling. If your host can do per-URI exclusions, push for that.

Which host is this btw? Some of them fight you on per-URI stuff because their panel only supports domain wide toggles, and then you're stuck.

FrostyBear

New Member
Messages
67
Reaction score
0
Location
Brisbane, AU

I'm pretty new to this whole WAF thing but the order notes field bit me too. Someone wrote "please select the blue one" in their notes and got 403'd at checkout. Didn't find out for like a week.

The per-URI exclusion thing greg_ohio mentioned is what I'd chase first. My host only does domain wide toggles, which is exactly as useless as it sounds, so I'm already shopping around. Who are you hosted with? If they support path level exclusions I want in.

Random question, has anyone tried just sanitizing the notes field on the app side before it ever hits the WAF? Feels dumb to strip apostrophes out of a customer note, but maybe less dumb than losing orders over it.

bananapeel42

New Member
Messages
53
Reaction score
0
Location
Manchester, UK

FrostyBear, please don't strip apostrophes from the notes field. You'll mangle real data (O'Brien, "don't ship until Tuesday," customers writing in a second language) to satisfy a regex that shouldn't be firing in the first place. Escape on output, leave the input alone.

Here's the thing nobody in this thread has said yet: the rule is dumb. A note field containing the word "select" is not SQL injection. Real SQLi is a payload hitting an unparameterized query, and if your notes field is parameterized then a customer can paste an entire injection cheat sheet into it and nothing happens. The WAF is patching around a vulnerability that probably doesn't exist in that field. greg_ohio is right that fail2ban won't cover checkout, but the actual fix is your app, not the regex.

That said, don't turn it off entirely. Ask your host if they can run the CRS in DetectionOnly mode for a week so you can see what's actually tripping without blocking anyone, then drop the paranoia level to PL1. A lot of hosts crank it to PL2 or higher because it sounds more secure, and that's where all the false positives live. PL1 plus per-URI exclusions on /checkout gets you most of the protection with a fraction of the noise.

Small thing worth checking first though: can your host show you the parameter that tripped the rule, or just the rule ID? Mine only gave me rule ID and URI, no parameter name, which made reproducing the 403s a nightmare until I just started fuzzing my own forms with apostrophes and the word "select" to see what broke. If you're stuck doing that too, at least you'll find them all at once.

maria_lopez

New Member
Messages
66
Reaction score
0
Location
Miami, FL

bananapeel42's DetectionOnly tip is correct but I'd push back on one part: "the fix is your app, not the regex" only gets you halfway. Even a perfectly parameterized notes field will still trip 942100 and 942430, because libinjection and the anomaly scoring don't know or care that your query is safe. Fixing the app stops you being vulnerable. It does not stop the WAF from eating orders. You still need the exclusion either way.

OP, which rule IDs are actually firing? If it's 942100 (libinjection) plus 942430 (restricted SQL char anomaly), those are the two that eat apostrophes and the word "select" in free text fields. Do NOT let the host whitelist the whole rule domain-wide, that's greg_ohio's point and it's the wrong scope. What you want is a target exclusion:

SecRuleUpdateTargetById 942100 "!ARGS:order_comments"

or the ctl:ruleRemoveTargetById equivalent inside a location block. Rule stays live everywhere else, only that parameter is exempt. Way narrower than a per-URI exclusion, and honestly better, because a path exclusion on /checkout turns off all 942xxx rules for every argument on that route.

What CRS version is the host running, and what paranoia level? PL2 is where the note-field false positives live, and a lot of budget hosts ship PL2 by default because it sounds better in the marketing. Also pull the audit log, not the error log. Error log won't tell you which ARGS var tripped it, you'll just see the 403 and waste an afternoon.

And yeah, don't strip apostrophes. FrostyBear's idea is the one thing in this thread that would actually corrupt data.

nightowl87

New Member
Messages
60
Reaction score
0
Location
Portland, OR

Wait, so the target exclusion is a thing? I've been assuming my only options were "whole rule off" or "get 403'd" and my host's panel only does domain-wide toggles anyway. No per-URI, no per-parameter. Which is why I ended up just killing the rule entirely and going back to feeling naked.

Question for maria_lopez though, does that SecRuleUpdateTargetById line care about the exact param name? Like if my form field is actually order_notes and not order_comments does it silently do nothing? Cause I could totally see myself pasting that in, thinking I fixed it, and losing another week of orders.

Also bananapeel42 the detection mode tip is on my list now. Gonna email the host and see if they'll flip it for a week. Half expecting them to say no tbh.

tallguy_tx

New Member
Messages
61
Reaction score
0
Location
Austin, TX

Yeah nightowl87, the param name has to match exactly. If your field is order_notes and you paste in !ARGS:order_comments, ModSec just shrugs and does nothing. No error, no warning, no log entry telling you the exclusion missed. You'll think you fixed it and keep eating 403s for another week. Ask me how I know.

The param name is whatever your app actually sends in the POST body, not the label on your form. Pull up devtools, submit a test order, look at the network tab. If it's a plugin or a page builder, the field name might be something ugly like wc_order_comments or field_7f3a, not the clean name you assumed. Maria_lopez's target exclusion is the right scope and better than the per-URI thing, but understand it's brittle. Rename a field, update the plugin, and the exclusion silently stops matching. So write down which param each exclusion points at, and re-test checkout after every update to that form.

Also agree with her pushback on bananapeel42. Fixing the app stops you being vulnerable, it does nothing to stop the WAF eating orders. Those are two separate problems and people keep collapsing them into one. Honestly the whole PL2/PL3 default thing is the same compliance theater I deal with everywhere else, the rule exists so the host can put "hardened WAF" on a sales page, and the actual breakage lands on you. My host won't even give me DetectionOnly, they told me it "weakens the security posture." Which is a nice way of saying their panel is too lazy to support it.

What CRS version is yours on? If it's ancient, some of those exclusions get ignored in ways the docs don't mention.

mike_t_2019

Member
Messages
60
Reaction score
0
Location
Leeds, UK

Nah, honestly, this is just another example of over-engineered bullshit, just like trying to deal with Ontario's latest regulations.

You're arguing about target exclusions and parameter names, which sounds super technical, but at the end of the day, it's all just about fighting an overly aggressive bureaucracy that decided that a casual note saying "please select the blue one" constitutes a SQL injection attempt. 🤦‍♂️

It's the same principle everywhere, tbh. Whether it's some host deciding your order notes are a threat, or the government deciding you need three permits just to buy a coffee, you're just dealing with a system designed to be maximal and restrictive. They don't want the functionality; they want the control.

Honestly, this whole WAF paranoia is a massive drag. If you’re having these kinds of issues, maybe you’re thinking too much about keeping everything secured within a conventional, highly-regulated infrastructure. I mean, I get it, you can't just flip a switch and become anonymous, but maybe you just need to move the point of sale somewhere they aren't so obsessed with finding a vulnerability in a customer's request.

I mean, crypto is the only place I've seen a system that actually respects the user and doesn't try to police the data unless it's straight-up malicious. At least with good offshore exchanges, the instant ETH payout is faster than figuring out if your form field is order_notes or wc_order_comments.

If the host is this defensive and hard to work with, maybe the cost of the security features is actually costing you more in lost orders and headaches than the risk of a simple SQLi. It's just regulatory theater, man.

marcus1987

New Member
Messages
66
Reaction score
0
Location
Sydney, NSW

tallguy_tx nailed the part that actually bit me. Nobody warns you the exclusion fails silently when the param name doesn't match. I spent three days convinced the host hadn't applied my rule, emailed them twice, then opened devtools and found my field was shipping as order_comments_1 because of some plugin prefix. Pasted the real name in, worked instantly. Felt like a moron.

On scope, maria_lopez is right and I'll die on that hill. A per-URI exclusion on /checkout kills every 942xxx rule for every argument on that route, including the ones you actually want watching. Target exclusion is the only sane option, assuming your host's panel even exposes it. Mine didn't. I had to get them to drop it into a conf include and that took four tickets and one very patient support guy.

mike_t_2019 I feel the Ontario rage in my bones, trust me. But moving your checkout to crypto doesn't dodge this one. ModSec eats the POST body before any payment processor sees it, doesn't care where the money was going. What actually changes things is getting off the shared host with the cranky panel and onto something where you own the conf file. Which, fine, is the same instinct that pushes people offshore in the first place. The compliance theater comparison is dead on though, a WAF cranked to PL3 by default is the same energy as a government form that exists to prove you filled out the other form.

People post host recommendations and param name horror stories over on the e-commerce board if anyone wants to dig through it

https://websiteforums.info/forums/e-commerce.17/

What CRS version is your host on? Wondering if the 942430 false positives got any better in the newer releases, cause I'm still fighting them.

rk_designs

New Member
Messages
68
Reaction score
0
Location
Vancouver, BC

marcus1987 that last line is the whole thing for me. I went offshore two years ago for reasons that have nothing to do with WAFs (my state has opinions about what adults are allowed to do with their own money) and the accidental perk is I can actually edit my own conf includes now. No ticket, no four day wait, no support guy asking me to "document the rule IDs."

So yeah, the target exclusion maria_lopez spelled out is the move and I run it basically the same way. But tallguy_tx nailed the ugly part. I had 942100 excluded on order_comments for like eight months, then a plugin update renamed the field and I started eating 403s again with nothing in the logs explaining why. Whole weekend gone. Devtools tab open the entire time staring me in the face, and I still checked the conf file first.

mike_t_2019 I get the rage, genuinely do. But crypto checkout doesn't dodge this one, marcus already said it and he's right, ModSec chews the POST body before any processor or wallet or whatever ever sees the order. What moving offshore actually buys you is root on your own box, and that's the only fix in this thread that doesn't come with an asterisk.

Side question for the room, what CRS version is everyone on? Mine's pinned to 3.3 and I'm scared to bump it in case the ruleset renumbers and every exclusion I wrote silently stops matching again.

You must log in or register to reply here.