Jump to content

File save forbidden, depending on text file content?


Recommended Posts

I'm very much a php newbie.  I have a game I wrote in Unity where I pack all my data into a text string and send it via a Unity Webrequest to my server where my Savedata.php file appends it to a text file.  Works beautifully.

Today I made some changes to my program, unrelated to any of the save routines.  When testing it, it wasn't saving the data.  The server was returning that it was Forbidden, leading to more than a bit of panic.   In my program the user enters a text string as an identifier that is put in the data string and saved.  I was putting "DELETE ME" as the id so that I could find it in the data file easily and delete it.   It was that Text that was triggering the save problem.   I changed it to "REMOVE ME" and saving worked just fine.

I assume the server is somehow checking the text data string and that there are some words that are illegal that trip an alarm and prevent it from being saved?   If so, are these (or other "no no's" I should be aware of) published/discussed anywhere?
Best,
Byron

I have 2 games using the same server, both using the same Unity Webrequest function to send data to my save_data.php file (one in each game directory).
In Game 1 if I put "DELETE" in my text string, I get the 404 Forbidden error.  In Game 2, I do not. 
I swapped Game 2's php to the Game 1 directory (they should have the same content) and the error persists.   

Game 1 won't save if the word "DELETE" or "delete" is in the textstring.  DELETEME works fine, so does DELET.  I imagine this is some kind of fringe case and I'll be fine so long as none of my users use "DELETE" as an ID, but since it doesn't seem logical that the system would work like this whatever is causing the error might cause it on other strings.    Any guesses would be appreciated.

Does this Server error help?

[Tue Feb 01 21:36:13.834953 2022] [:error] [pid 31899:tid 139931882379008] [client 95.63.28.231:57246] [client 95.63.28.231] ModSecurity: Access denied with code 403 (phase 2). Pattern match "(?:\\\\n|\\\\r)+(?:get|post|head|options|connect|put|delete|trace|propfind|propatch|mkcol|copy|move|lock|unlock)\\\\s+" at MATCHED_VAR. [file "/etc/modsecurity/12_HTTP_Protocol.conf"] [line "137"] [id "217280"] [rev "6"] [msg "WAF: HTTP Request Smuggling Attack||www.learningchicken.com|F|2"] [data "Matched Data: delete found within MATCHED_VAR"] [severity "CRITICAL"] [tag "CWAF"] [tag "Protocol"] [hostname "www.learningchicken.com"] [uri "/JBN/EvsC_Chicken/save_data.php"] [unique_id "YfmZvVJimwoAAHybrfYAAAAA"]

Its shared hosting. I imagine it unlikely that any user will use any of these "get|post|head|options|connect|put|delete|trace|propfind|propatch|mkcol|copy|move|lock|unlock" in their username, but I suppose I'll scan it anyway and either remove or replace them if they are used.

Yeah, don't do that.

See if your hosting provider is willing (and able) to turn off mod_security for you: it's a great thing in theory but reports so many false positives that it just ends up being a pain in the ass.

If that's not an option, all you have to do to bypass this particular security measure is to encode the data. For example, with base 64. Submit the data encoded and have your PHP decode it.

  • Thanks 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.