Closed martinburchell closed 1 year ago
This turns out to be a problem with the Microsoft Azure Web Application Firewall sitting in front of CamCOPS and nothing to do with CamCOPS itself:
The original failing request:
curl -d "camcops_version=2.4.17&device=%7B33682cea-6094-40cf-9a10-b2906103b221%7D&fields=id%2C_move_off_tablet%2Cwhen_last_modified%2Cwhen_created%2Cfirstexit_is_finish%2Cfirstexit_is_abort%2Cwhen_firstexit%2Cediting_time_s%2Cpatient_id%2Clast_stage%2Cmax_trials_per_stage%2Cprogress_criterion_x%2Cprogress_criterion_y%2Cmin_number%2Cmax_number%2Cpause_after_beep_ms%2Citi_ms%2Ccounterbalance_dimensions%2Cvolume%2Coffer_abort%2Cdebug_display_stimuli_only%2Cshape_definitions_svg%2Ccolour_definitions_rgb%2Caborted%2Cfinished%2Clast_trial_completed&nrecords=1&operation=upload_table&password=mypasswordredacted&pkname=id&record0=1%2CNULL%2C%272023-10-24T15%3A10%3A55.106%2B01%3A00%27%2C%272023-10-24T15%3A07%3A33.625%2B01%3A00%27%2C1%2C0%2C%272023-10-24T15%3A07%3A44.704%2B01%3A00%27%2C201.443%2C1%2C8%2C50%2C6%2C6%2C1%2C9%2C500%2C500%2C3%2C0.5%2C0%2C0%2C%27%5B%22m10%2C-53%20l20%2C100%20l-60%2C0%20z%20m50%2C60%20l-120%2C20%20l0%2C-50%20z%22%2C%22m0%2C-50%20l-57%2C57%20l28%2C28%20l28%2C-28%20l28%2C28%20l28%2C-28%20z%22%2C%22m-15%2C-50%20l-45%2C25%20l90%2C0%20z%20m15%2C35%20l-45%2C25%20l90%2C0%20z%20m15%2C35%20l-45%2C25%20l90%2C0%20z%22%2C%22m-60%2C-11%20l94%2C55%20l26%2C-28%20l-38%2C-15%20l38%2C-15%20l-26%2C-28%20l-94%2C55%20z%22%2C%22m-20%2C-50%20l-40%2C50%20l45%2C0%20l0%2C50%20l30%2C0%20l0%2C-50%20l45%2C0%20l-45%2C-50%20z%22%2C%22m-60%2C-36%20l120%2C0%20l0%2C72%20l-40%2C0%20l0%2C-36%20l-40%2C0%20l0%2C36%2C%20l-40%2C0%20z%22%2C%22m0%2C-40%20l60%2C40%20l-40%2C27%20l0%2C13%20l-40%2C0%20l0%2C-13%20l-40%2C-27%20z%22%2C%22m-33%2C40%20l-27%2C-40%20l27%2C-40%20l33%2C27%20l33%2C-27%20l27%2C40%20l-27%2C40%20l-33%2C-27%20z%22%2C%22m-60%2C-30%20l60%2C-30%20l60%2C30%20l0%2C60%20l-60%2C30%20l-60%2C-30%20z%22%2C%22m-60%2C60%20l120%2C0%20l-60%2C-60%20z%20m0%2C-120%20l120%2C0%20l-60%2C60%20z%22%2C%22m-60%2C-40%20l0%2C68%20l120%2C0%20l-45%2C-30%20l0%2C11%20l-45%2C-38%20l0%2C23%20z%22%2C%22m-60%2C0%20l34%2C-43%20l86%2C0%20l-34%2C43%20l34%2C43%20l-86%2C0%20z%22%5D%27%2C%27%5B%22%23555555%22%2C%22%235555ff%22%2C%22%2355ff55%22%2C%22%2355ffff%22%2C%22%23ff5555%22%2C%22%23ff55ff%22%2C%22%23ffff55%22%2C%22%23ffffff%22%5D%27%2C0%2C1%2C60&session_id=5562616&session_token=Jmm0YmRMeMf1KAJ_SZ3-PA%3D%3D&table=ided3d&user=myuser" -X POST https://camcops.example.org/api
This seems to be enough to trigger the 403:
curl -d "foo=%22%22" -X POST https://camcops.example.org/api`
This is a working request for a different task in so much as it gets through the firewall:
curl -d "camcops_version=2.4.17&device=%7B33682cea-6094-40cf-9a10-b2906103b221%7D&fields=id%2C_move_off_tablet%2Cwhen_last_modified%2Cwhen_created%2Cfirstexit_is_finish%2Cfirstexit_is_abort%2Cwhen_firstexit%2Cediting_time_s%2Cpatient_id%2Cq1%2Cq2%2Cq3%2Cq4%2Cq5%2Cq6%2Cq7&nrecords=1&operation=upload_table&password=mypasswordredacted&pkname=id&record0=1%2CNULL%2C%272023-10-24T15%3A00%3A54.547%2B01%3A00%27%2C%272023-10-24T15%3A00%3A45.862%2B01%3A00%27%2C1%2C0%2C%272023-10-24T15%3A00%3A54.546%2B01%3A00%27%2C8.661%2C1%2C0%2C0%2C0%2C0%2C0%2C0%2C" -X POST https://camcops.example.org/api`
Fixed by turning off the OWASP rule that was blocking %22 (the double quote character)
The OWASP rules in question in this case were 942110 and 942330 (SQL injection)
User reported problem uploading data to the server. By switching to multi-step mode, tracked down to the ID/ED-3D task (interleaved log files from client, Apache and server). Note the last request does not reach Apache:
Request 1
Request 2
Request 3
Request 4
Request 5
Request 6
Request 7
Request 8
Request 9
Request 10
Request 11
Request 12
Request 13
Request 14
Request 15
Request 16