Forum Moderators: phranque

Message Too Old, No Replies

Bad Request - header field too large

Bad Request (Error 400) due to very large cookies

         

denby

11:28 pm on Feb 29, 2004 (gmt 0)

10+ Year Member



Hi

Some of my users have reported a Bad Request error which is blocking their access to my whole site. I believe it is caused by the presence of some large and redundant cookies on their machines. (See message below.) I had success with one user who emailed me, by suggesting she delete all my site's cookies from her machine. But what about other users who haven't got my email address and are now locked out of my site?

Is there some way I can delete the old redundant cookies for them? I guess I can't do that from my site because the users never get past the Bad Request error. I thought I could use ErrorDocument redirection to another server (my old host where I still have access to some server space) to run a Perl script which would delete the old cookies (and then redirect them back to my site). But that has its problems, including the looming lapse of my access to that server and the possibility the same error may be generated by that server.

I suppose I could mass email all my registered users (the only ones who would have these old cookies) and tell them to delete the cookies but many users wouldn't know how to go about it. What to do?

help!

Denby

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Bad Request

Your browser sent a request that this server could not understand.

Size of a request header field exceeds server limit.

Cookie:
tbwforum_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%2223f9d50ecd20ccc464f4ad45a3328948%22
%3Bs%3A6%3A%22userid%22%3Bi%3A6%3B%7D;
tbwforum_username=TwinMommy2003; tbwforum_sid=37b3d793094a7086ba9d73e892891af4; tbwforum_t=a%3A150%3A%7Bi%3A93%3Bi%3A1074049762%3Bi%3A405%3Bi%3A1074051025%3Bi%3A403%3Bi
%3A1074087968%3Bi%3A415%3Bi%3A1074101097%3Bi%3A411%3Bi%3A1074124350%3Bi%3A414%3Bi
%3A1074134490%3Bi%3A361%3Bi%3A1074199800%3Bi%3A419%3Bi%3A1074200235%3Bi%3A406%3Bi
%3A1074201680%3Bi%3A400%3Bi%3A1074201768%3Bi%3A424%3Bi%3A1074393447%3Bi%3A425%3Bi
%3A1074393751%3Bi%3A397%3Bi%3A1074394164%3Bi%3A408%3Bi%3A1074395536%3Bi%3A428%3Bi
%3A1074395791%3Bi%3A433%3Bi%3A1074438997%3Bi%3A434%3Bi%3A1074445124%3Bi%3A431%3Bi
%3A1074445144%3Bi%3A386%3Bi%3A1074445237%3Bi%3A441%3Bi%3A1074445491%3Bi%3A392%3Bi
%3A1074445606%3Bi%3A85%3Bi%3A1074445651%3Bi%3A445%3Bi%3A1074446467%3Bi%3A447%3Bi
%3A1074446578%3Bi%3A395%3Bi%3A1074449253%3Bi%3A371%3Bi%3A1074455110%3Bi%3A407%3Bi
%3A1074462311%3Bi%3A443%3Bi%3A1074462409%3Bi%3A453%3Bi%3A1074563788%3Bi%3A461%3Bi
%3A1074563911%3Bi%3A456%3Bi%3A1074564725%3Bi%3A159%3Bi%3A1074564825%3Bi%3A452%3Bi
%3A1074565129%3Bi%3A337%3Bi%3A1074565220%3Bi%3A462%3Bi%3A1074603356%3Bi%3A177%3Bi
%3A1074609332%3Bi%3A466%3Bi%3A1074612346%3Bi%3A355%3Bi%3A1074635600%3Bi%3A464%3Bi
%3A1074635624%3Bi%3A399%3Bi%3A1074649636%3Bi%3A450%3Bi%3A1074688286%3Bi%3A451%3Bi
%3A1074688314%3Bi%3A449%3Bi%3A1074699445%3Bi%3A482%3Bi%3A1074699842%3Bi%3A124%3Bi
%3A1074700903%3Bi%3A470%3Bi%3A1074720387%3Bi%3A475%3Bi%3A1074723323%3Bi%3A409%3Bi
%3A1074723669%3Bi%3A471%3Bi%3A1074724541%3Bi%3A413%3Bi%3A1074729912%3Bi%3A458%3Bi
%3A1074737552%3Bi%3A463%3Bi%3A1074775308%3Bi%3A487%3Bi%3A1074776744%3Bi%3A420%3Bi
%3A1074778929%3Bi%3A410%3Bi%3A1074779304%3Bi%3A325%3Bi%3A1074796916%3Bi%3A492%3Bi
%3A1074798659%3Bi%3A488%3Bi%3A1074805021%3Bi%3A486%3Bi%3A1074805519%3Bi%3A483%3Bi
%3A1074805670%3Bi%3A491%3Bi%3A1074810079%3Bi%3A497%3Bi%3A1074810102%3Bi%3A496%3Bi
%3A1074810787%3Bi%3A500%3Bi%3A1074812716%3Bi%3A446%3Bi%3A1074812776%3Bi%3A494%3Bi
%3A1074812841%3Bi%3A465%3Bi%3A1074821033%3Bi%3A495%3Bi%3A1074862503%3Bi%3A490%3Bi
%3A1074893157%3Bi%3A493%3Bi%3A1074893709%3Bi%3A469%3Bi%3A1074900248%3Bi%3A511%3Bi
%3A1074900525%3Bi%3A506%3Bi%3A1074900537%3Bi%3A513%3Bi%3A1074900974%3Bi%3A508%3Bi
%3A1074901067%3Bi%3A207%3Bi%3A1074952721%3Bi%3A510%3Bi%3A1074952873%3Bi%3A503%3Bi
%3A1074953167%3Bi%3A468%3Bi%3A1074953177%3Bi%3A476%3Bi%3A1074953205%3Bi%3A472%3Bi
%3A1074953212%3Bi%3A499%3Bi%3A1074953243%3Bi%3A473%3Bi%3A1074955592%3Bi%3A505%3Bi
%3A1074955596%3Bi%3A507%3Bi%3A1074955603%3Bi%3A512%3Bi%3A1074955621%3Bi%3A359%3Bi
%3A1074955971%3Bi%3A489%3Bi%3A1075041621%3Bi%3A279%3Bi%3A1075058221%3Bi%3A484%3Bi
%3A1075078108%3Bi%3A151%3Bi%3A1075078600%3Bi%3A524%3Bi%3A1075081686%3Bi%3A527%3Bi
%3A1075082112%3Bi%3A530%3Bi%3A1075083349%3Bi%3A529%3Bi%3A1075084060%3Bi%3A528%3Bi
%3A1075084574%3Bi%3A515%3Bi%3A1075122314%3Bi%3A516%3Bi%3A1075122392%3Bi%3A532%3Bi
%3A1075154291%3Bi%3A533%3Bi%3A1075164437%3Bi%3A521%3Bi%3A1075164955%3Bi%3A518%3Bi
%3A1075164993%3Bi%3A519%3Bi%3A1075165034%3Bi%3A481%3Bi%3A1075165927%3Bi%3A526%3Bi
%3A1075169236%3Bi%3A535%3Bi%3A1075210947%3Bi%3A416%3Bi%3A1075211534%3Bi%3A440%3Bi
%3A1075211636%3Bi%3A432%3Bi%3A1075212459%3Bi%3A477%3Bi%3A1075212489%3Bi%3A539%3Bi
%3A1075227159%3Bi%3A525%3Bi%3A1075227179%3Bi%3A439%3Bi%3A1075227283%3Bi%3A542%3Bi
%3A1075228214%3Bi%3A536%3Bi%3A1075331534%3Bi%3A545%3Bi%3A1075331672%3Bi%3A343%3Bi
%3A1075331698%3Bi%3A313%3Bi%3A1075333408%3Bi%3A202%3Bi%3A1075334361%3Bi%3A173%3Bi
%3A1075334393%3Bi%3A541%3Bi%3A1075334496%3Bi%3A552%3Bi%3A1075334559%3Bi%3A480%3Bi
%3A1075334804%3Bi%3A547%3Bi%3A1075341054%3Bi%3A543%3Bi%3A1075341086%3Bi%3A269%3Bi
%3A1075341147%3Bi%3A553%3Bi%3A1075342236%3Bi%3A554%3Bi%3A1075342240%3Bi%3A548%3Bi
%3A1075342250%3Bi%3A544%3Bi%3A1075342369%3Bi%3A252%3Bi%3A1075393292%3Bi%3A517%3Bi
%3A1075393930%3Bi%3A556%3Bi%3A1075394032%3Bi%3A559%3Bi%3A1075394130%3Bi%3A558%3Bi
%3A1075394166%3Bi%3A560%3Bi%3A1075394191%3Bi%3A557%3Bi%3A1075394542%3Bi%3A555%3Bi
%3A1075413707%3Bi%3A562%3Bi%3A1075413749%3Bi%3A561%3Bi%3A1075414687%3Bi%3A564%3Bi
%3A1075414866%3Bi%3A565%3Bi%3A1075414911%3Bi%3A549%3Bi%3A1075415674%3Bi%3A538%3Bi
%3A1075416883%3Bi%3A566%3Bi%3A1075417115%3Bi%3A531%3Bi%3A1075467504%3Bi%3A537%3Bi
%3A1075467582%3Bi%3A568%3Bi%3A1075468208%3Bi%3A522%3Bi%3A1075467880%3Bi%3A567%3Bi
%3A1075468016%3B%7D; tbwforumlp_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%2223f9d50ecd20ccc464f4ad45a3328948%22
%3Bs%3A6%3A%22userid%22%3Bi%3A6%3B%7D; tbwforumlp_sid=98f7fca7b113fbea88785f94915c03d3; tbwforumlp_username=TwinMommy2003; tbwforumlp_t=a%3A135%3A%7Bi%3A609%3Bi%3A1076378395%3Bi%3A630%3Bi
%3A1076363732%3Bi%3A313%3Bi%3A1077744804%3Bi%3A616%3Bi%3A1076366885%3Bi%3A627%3Bi
%3A1076117540%3Bi%3A629%3Bi%3A1076117886%3Bi%3A634%3Bi%3A1076118035%3Bi%3A628%3Bi
%3A1076118601%3Bi%3A633%3Bi%3A1076118710%3Bi%3A640%3Bi%3A1076216015%3Bi%3A584%3Bi
%3A1076205587%3Bi%3A641%3Bi%3A1076205882%3Bi%3A531%3Bi%3A1077895970%3Bi%3A537%3Bi
%3A1076716652%3Bi%3A646%3Bi%3A1076889178%3Bi%3A644%3Bi%3A1076888614%3Bi%3A645%3Bi
%3A1076256387%3Bi%3A654%3Bi%3A1076344817%3Bi%3A653%3Bi%3A1076345660%3Bi%3A488%3Bi
%3A1076376257%3Bi%3A650%3Bi%3A1076360157%3Bi%3A623%3Bi%3A1076360377%3Bi%3A659%3Bi
%3A1076420372%3Bi%3A655%3Bi%3A1076716780%3Bi%3A194%3Bi%3A1076467960%3Bi%3A660%3Bi
%3A1076377577%3Bi%3A661%3Bi%3A1076366364%3Bi%3A620%3Bi%3A1076542603%3Bi%3A582%3Bi
%3A1076381035%3Bi%3A663%3Bi%3A1077069823%3Bi%3A666%3Bi%3A1077503428%3Bi%3A667%3Bi
%3A1076422292%3Bi%3A669%3Bi%3A1076540864%3Bi%3A673%3Bi%3A1076897167%3Bi%3A64%3Bi
%3A1076540983%3Bi%3A683%3Bi%3A1076541078%3Bi%3A679%3Bi%3A1077576951%3Bi%3A674%3Bi
%3A1076541712%3Bi%3A618%3Bi%3A1076541850%3Bi%3A213%3Bi%3A1076808230%3Bi%3A672%3Bi
%3A1076606186%3Bi%3A685%3Bi%3A1076607439%3Bi%3A686%3Bi%3A1076607537%3Bi%3A687%3Bi
%3A1076723932%3Bi%3A688%3Bi%3A1076607574%3Bi%3A682%3Bi%3A1076607593%3Bi%3A207%3Bi
%3A1077504063%3Bi%3A690%3Bi%3A1076626035%3Bi%3A420%3Bi%3A1076628353%3Bi%3A343%3Bi
%3A1076635928%3Bi%3A689%3Bi%3A1076716699%3Bi%3A613%3Bi%3A1076725140%3Bi%3A692%3Bi
%3A1077577286%3Bi%3A247%3Bi%3A1076768265%3Bi%3A368%3Bi%3A1076768334%3Bi%3A569%3Bi
%3A1076768394%3Bi%3A699%3Bi%3A1076768452%3Bi%3A703%3Bi%3A1076806741%3Bi%3A704%3Bi
%3A1076947151%3Bi%3A700%3Bi%3A1076806883%3Bi%3A694%3Bi%3A1077070571%3Bi%3A708%3Bi
%3A1076809010%3Bi%3A705%3Bi%3A1077114115%3Bi%3A702%3Bi%3A1076809288%3Bi%3A706%3Bi
%3A1076845690%3Bi%3A710%3Bi%3A1076896454%3Bi%3A713%3Bi%3A1076947323%3Bi%3A712%3Bi
%3A1076888585%3Bi%3A557%3Bi%3A1076889252%3Bi%3A299%3Bi%3A1076897275%3Bi%3A701%3Bi
%3A1076947466%3Bi%3A717%3Bi%3A1077155089%3Bi%3A716%3Bi%3A1077503093%3Bi%3A718%3Bi
%3A1076982463%3Bi%3A721%3Bi%3A1077647904%3Bi%3A720%3Bi%3A1076983109%3Bi%3A722%3Bi
%3A1077069040%3Bi%3A725%3Bi%3A1077111285%3Bi%3A726%3Bi%3A1077113519%3Bi%3A728%3Bi
%3A1077156560%3Bi%3A729%3Bi%3A1077754371%3Bi%3A740%3Bi%3A1077388219%3Bi%3A738%3Bi
%3A1077754147%3Bi%3A730%3Bi%3A1077851197%3Bi%3A101%3Bi%3A1077330915%3Bi%3A421%3Bi
%3A1077330965%3Bi%3A746%3Bi%3A1077479127%3Bi%3A745%3Bi%3A1077479153%3Bi%3A754%3Bi
%3A1077491115%3Bi%3A755%3Bi%3A1077547099%3Bi%3A747%3Bi%3A1077837197%3Bi%3A743%3Bi
%3A1077502435%3Bi%3A753%3Bi%3A1077502546%3Bi%3A744%3Bi%3A1077503549%3Bi%3A742%3Bi
%3A1077503797%3Bi%3A736%3Bi%3A1077504150%3Bi%3A751%3Bi%3A1077504263%3Bi%3A752%3Bi
%3A1077752660%3Bi%3A757%3Bi%3A1077626621%3Bi%3A760%3Bi%3A1077748930%3Bi%3A762%3Bi
%3A1077568800%3Bi%3A763%3Bi%3A1077570780%3Bi%3A764%3Bi%3A1077577397%3Bi%3A761%3Bi
%3A1077577467%3Bi%3A759%3Bi%3A1077648001%3Bi%3A733%3Bi%3A1077590322%3Bi%3A766%3Bi
%3A1077850964%3Bi%3A768%3Bi%3A1077631382%3Bi%3A777%3Bi%3A1077729274%3Bi%3A781%3Bi
%3A1077745315%3Bi%3A780%3Bi%3A1077849340%3Bi%3A302%3Bi%3A1077747351%3Bi%3A782%3Bi
%3A1077747424%3Bi%3A769%3Bi%3A1077976914%3Bi%3A774%3Bi%3A1077751427%3Bi%3A779%3Bi
%3A1077762735%3Bi%3A775%3Bi%3A1077851054%3Bi%3A784%3Bi%3A1077762872%3Bi%3A771%3Bi
%3A1077845705%3Bi%3A776%3Bi%3A1077850911%3Bi%3A794%3Bi%3A1077840492%3Bi%3A795%3Bi
%3A1077851632%3Bi%3A790%3Bi%3A1077845648%3Bi%3A789%3Bi%3A1077849604%3Bi%3A786%3Bi
%3A1077850181%3Bi%3A785%3Bi%3A1077850481%3Bi%3A778%3Bi%3A1077850695%3Bi%3A115%3Bi
%3A1077850739%3Bi%3A732%3Bi%3A1077851116%3Bi%3A796%3Bi%3A1077928028%3Bi%3A788%3Bi
%3A1077851564%3Bi%3A797%3Bi%3A1077896359%3Bi%3A809%3Bi%3A1077933798%3Bi%3A811%3Bi
%3A1077977533%3Bi%3A808%3Bi%3A107

--------------------------------------------------------------------------------

Apache/1.3.29 Server at valina.example.com Port 80
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

[edited by: jdMorgan at 12:36 am (utc) on Mar. 1, 2004]
[edit reason] Fixed page wrap, examplified URL [/edit]

jdMorgan

11:51 pm on Feb 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



denby,

That is *waaay* too much cookie, either for a site or for this forum.

If this were my site, this is what I would do.
1) Get the person who wrote the code that creates the cookies into a room with a computer and basic office resources.
2) Lock the door. From the outside.
3) Have that person write you a "cookie recovery" routine that will recover the user's most basic information from the cookie, drop all the fluff, and re-write the user's cookie.
4) Have that person rewrite the normal cookie-handling routine to make it "self-cleaning," so this problem will never happen again.
5) Have that person test the code on several of these huge cookies, and prove to you that it works.
6) Install the cookie recovery code on your live site.
7) Change your server configuration to allow requests only slightly larger than the ones that are failing now.
8) Put up a message on your site that apologizes for the loss of customized user settings.
9) Take the new site live.
10) After 24 hours of successful operation, release the captive.

The reason for the "only slight increase" in step 7 is to make sure you can increase it again if this does not work. Ultimately, you will hit the fixed server limit, and if you haven't got all cookies repaired by then, you are sunk.

Jim

denby

4:16 am on Mar 1, 2004 (gmt 0)

10+ Year Member



Thanks for your wise words. I am the prospective captive I fear! Whip me, whip me...

But what about the users who are now locked out (if I can't have the limit altered)?


Is there some way I can delete the old redundant cookies for them? I guess I can't do that from my site because the users never get past the Bad Request error. I thought I could use ErrorDocument redirection to another server (my old host where I still have access to some server space) to run a Perl script which would delete the old cookies (and then redirect them back to my site). But that has its problems, including the looming lapse of my access to that server and the possibility the same error may be generated by that server.

help! (again)

jdMorgan

4:50 am on Mar 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I suppose the simplest answer would be to use a custom 400-Bad Request error document, and have that document (a script) unconditionally send a "blank" cookie with a short expiry time to the user-agent.

If you want to do it with PERL, then you'd use something like:


ErrorDocument 400 /clear_that_huge_cookie.pl

in your top-level .htaccess file. If a "bad request" is received, Apache will transfer control to the specified page or script, and the clear_that_huge_cookie.pl script would then contain the code to output the response headers required to update the existing cookie for the requested domain and URL with a blank or default value -- Note that the originally-requested URL will still be available to the script, since an ErrorDocument invokation *is not* an external redirect.

I don't know enough about complex cookie usage to tell you more, but you may find the documents cited in Apache mod_usertrack [httpd.apache.org] (RFC 2109, RFC2965, etc.) to be useful.

Jim

denby

12:18 pm on Mar 1, 2004 (gmt 0)

10+ Year Member



If a "bad request" is received, Apache will transfer control to the specified page or script, and the clear_that_huge_cookie.pl script would then contain the code to output the response headers required to update the existing cookie for the requested domain and URL with a blank or default value -- Note that the originally-requested URL will still be available to the script, since an ErrorDocument invokation *is not* an external redirect.

That sounds good. Can I just clarify something? When my clear_that_huge_cookie.pl script deletes the old cookie (and sends the new cookie), using say CGI.pm to write data to the header and "print" it to the browser, it WON'T result in a new Bad Request? Wierd but good!

Thanks for your help.

Denby

jdMorgan

4:49 pm on Mar 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



denby,

Well, I really don't know, but that's the only solution that comes to mind if you can't change the server's LimitRequestFieldSize settings.

Note that I was proposing that you simply use something like:


#!/usr/bin/perl
print ("Content-type: text/plain\n");
print ("Set-Cookie: tbwforum_data=\"0\"; Max-Age=\"0\"\n\n");
exit;

in the .pl file to create a response header that expires the existing cookie immediately. This may or may not work, depending on whether I interpreted the syntax requirements correctly. You may also have to include the domain and path info -- and possibly more -- to get it to work.

Looking through the documents cited by mod_usertrack, that looks like the easiest way.

You could also create a more complex response header to actually set the cookie to whatever default value you prefer. And, you could conceivably even have your script extract some of the useful information from the over-size cookie you've already received and send that back to the client - thus "repairing" at least some of the user settings.

This is beyond anything I've ever done, and I'm afraid it's up to you to determine if such an approach would work and how to implement it. But you need to do the "fix" in the 400 response header, so that no further "handshakes" with the client occur before the cookie is deleted or repaired. Otherwise, you'll end up in a loop.

The trick here is to use a minimalist approach, so that you don't introduce any additional dependencies.

Hopefully, this thread will attract the attention of a member who knows more about cookie-handling than I do.

Jim