Patron reports nginx error when adding edition
Problem
Patron tried adding an edition to https://openlibrary.org/books/add?work=/works/OL7985449W and tried https://openlibrary.org/books/add.
Reproducing the bug
- Go to ... https://openlibrary.org/books/add?work=/works/OL7985449W
- Do ... add new edition
- Expected behavior:
- Actual behavior: 403 Forbidden - nginx error.
Context
- Browser (Chrome, Safari, Firefox, etc):
- OS (Windows, Mac, etc):
- Logged in (Y/N):
- Environment (prod, dev, local): prod
Breakdown
Implementation Details (for maintainers)
Requirements Checklist
- [ ]
Related files
Stakeholders
Instructions for Contributors
- Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
Hi @seabelis , I'd like to work on this issue. I'll try to reproduce the 403 error and check why the request is getting blocked. If you have any related logs or know which rule is causing this, could you please share them? It would help me understand the issue better. I'll try to find a fix without affecting the existing security.
@seabelis I'd like to help with this one. @iamshravanijadhav asked the right question above — which rule fired — so rather than repeat it, here is where that answer has to come from.
The ruleset isn't in this repo. docker/web_nginx.conf:111-112:
modsecurity on;
modsecurity_rules_file /olsystem/etc/nginx/modsecurity_openlibrary.conf;
olsystem is the separate private config repo — the same place deny.conf, is_blessed_ip.conf and is_sus_ip.conf come from (docker/nginx.conf:50-59). This repo carries only scripts/build_modsecurity.sh, which builds the module, not the rules. Two consequences:
- Nobody outside staff can say which rule matched.
- It won't reproduce locally — a dev container has no
/olsystemmount, so ModSecurity never engages.
What would unblock it, cheapest first:
- The ModSecurity audit-log entry for one failing request. The rule ID and matched variable are the entire answer. jimchamp's daily anonymized ModSecurity log pipeline (#13225) may already have this — it uploads an anonymized error log to an archive.org item each day.
- Failing that, narrowing it: is the 403 on the
GETof/books/add, or on thePOSTthat submits the form? The report names both URLs, which reads like the POST. An edition form POSTs a lot of free-text fields, which is a classic false-positive shape for the OWASP CRS SQLi/XSS rules — and false positives are exactly what the ModSecurity work in #13194 item 3 exists to clear.
Happy to do the step-2 narrowing if someone with log access can paste an entry, and to take the fix once the rule ID is known. Flagging that Needs: Lead and Needs: Triage are accurate here — this needs olsystem access before it's an implementable task for anyone.
Fun fact, none of you can work on this issue as it related to WAF (Wireless Application Firewalls) + modsecurity. :)