Closed Bug 55878 Opened 26 years ago Closed 26 years ago

Crash while submitting a form from 127.0.0.1

Categories

(Core :: Security, defect, P3)

x86
Linux
defect

Tracking

()

VERIFIED FIXED
Future

People

(Reporter: mail, Assigned: morse)

Details

(Whiteboard: [rtm-])

Attachments

(1 file)

From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.14 i686; en-US; m18) Gecko/20001007 BuildID: 2000100721 Mozilla crashes if you try to submit a form which is saved on or generated by a local web server and accessed with http://127.0.0.1/path/to/page.htm. Reproducible: Always Steps to Reproduce: Set up a web server (on Linux, you often already have the Apache web server installed). (By the way: I haven't reproduced this problem on Win32 yet.) Then save the followed file with any name in the web files directory (or print it out with a CGI script): ==== HTML file begin ==== <html> <head><title>Let's crash again</title></head> <body> <form action="/cgi-bin/nothing.pl" method="put"> <!-- Yes, nothing.pl doesn't have to exist and you can write "get" as method as well. //--> <input type="hidden" name="name" value="something"> <input type="submit" value="Let's crash"> </form> </body> </html> ==== HTML file end ==== Open the file with http://127.0.0.1/path/to/file.htm (or http://127.0.0.1/cgi-bin/path/to/script.cgi) and submit the form. Huh? Where's Mozilla? Actual Results: Mozilla crashes. Expected Results: Mozilla should submit the data (and show me the results). I could reproduce the bug since I needed to submit a local form. Sorry that I wasn't able to search for similar bugs - I've got always a timeout with the search form of http://www.mozilla.org/quality/help/bugzilla-helper.html. It's nearly impossible that I'm the only one who has this problem...
darin: can you confirm/investigate this? thx.
Assignee: gagan → darin
[Linux build 2000100909] and [Linux build 2000100610] I'm not able to confirm the crash; however, instead mozilla hangs for about 5 seconds. Afterwards, it does not display any kind of error message. If I instead use "localhost" for the server address, I don't run into this problem, and I immediately see the "Not Found" message. So, there is definitely something about 127.0.0.1 that is buggy!
Keywords: rtm
I also don't see this problem if I use the machine's actual IP address.
Reporter, please verify the crash against the latest build.
In 2000100721, I can't even open an URL like http://localhost/xit/cltest1.htm. Now, I ran it from konsole: ===== Output begin ===== [xitnalta@linux] [~/mozilla/package] ./mozilla ./run-mozilla.sh ./mozilla-bin MOZILLA_FIVE_HOME=. LD_LIBRARY_PATH=.:/home/xitnalta/adabas/lib:/usr/local/qt/lib:/usr/local/lib:/home/xitnalta/adabas/lib: LIBRARY_PATH=.:./components SHLIB_PATH=. LIBPATH=. ADDON_PATH=. MOZ_PROGRAM=./mozilla-bin MOZ_TOOLKIT= moz_debug=0 moz_debugger= Setting content window *** Pulling out the charset Loading page specified via openDialog in SetSecurityButton Document file:///home/xitnalta/Dokumente/Dokumentationen/SELFHTML/selfhtml.htm loaded successfully Document http://127.0.0.1/xit/crtest2.htm loaded successfully ./run-mozilla.sh: line 72: 559 Speicherzugriffsfehler $prog ${1+"$@"} [xitnalta@linux] [~/mozilla/package] ===== Output end ===== It's the code I used in the description. If I use my real IP, 194.230.xxx.xxx, I haven't any problems, but it's better to have a bookmark to a 127.0.0.1 address rather than finding out my real IP every time (or setting up a forwarder). Now, there are 9 minutes left for the newest build... (http://ftp.mozilla.org/pub/mozilla/nightly/2000-10-09-18-M18/mozilla-i686-pc-linux-gnu.tar.gz)
Linux build 2000100918: Same problems, I can't load a localhost URL and am unable to submit form data from a 127.0.0.1 URL. No problems with these URLs in lynx. I get a 404 with the example file and working results with my CGI work. Ah, and I'm using SuSE 6.4. I don't believe that it's a problem of Linux but it could be...
Hmmm... seems like this might be a dup of (or related to) bug 50929. Either way I don't think this will make it past the PDT for rtm.
Whiteboard: [rtm-]
Maybe it is something related to SuSE Linux... I've been testing on RedHat 6.2 and 7.0. What version of libc is on your system?
yast shows me the following: libc - version 2.1.3-58 (installed) contains glibc-2.1 glibc-crypt-2.1 glibc-nss-v1-2.0.2 ... bug 50929 complains about some problems with localhost and searching (?). It's related to my problems with localhost URLs (I can't access a localhost URL), but it's not exactly the same (see below). And there's nothing about submitting form data from 127.0.0.1 (so this bug isn't a dup of bug 50929). I get the following message (build 2000100918) if I try "http://localhost/": "The connection was refused when attempting to contact localhost." "lynx http://localhost/" works as expected.
We're definitely running different versions of glibc (RH7=libc-2.1.92), but who knows if that really is the source of the problem. I'm really out of ideas!
Let's try! I download now a newer RPM with FTP. I'll give you a notice what happens if it's here. (Now testing with Linux build 2000101015)
I'm Sorry, I got libc 2.1.3-154 and no changes.
I heard about a interesting project related to such problems as this bug is one. The Free Standards Group released specifications for Linux developers about how to write software (which libraries etc. to use) that their applications run on all distributions: http://www.freestandards.org/news/2000/20001011.shtml.
Linux build 2000101608 still crashes.
Any chance you could generate a stack dump?
Yes - if you show me how :o). If there's an URL which explains it, just post.
http://www.mozilla.org/unix/debugging-faq.html Read the FAQ to help you understand some of the nuances of debugging mozilla, then get a copy of the source and compile (nightly builds don't have debugging symbols). Once you get it compiled, run mozilla from the debugger. When it crashes, you'll see the SIGSEGV reported in GDB, then just type "bt" to get a stack dump.
I'll do it later (this month) :).
->futured pending stack dump from reporter
Target Milestone: --- → Future
Status: UNCONFIRMED → NEW
Ever confirmed: true
Setting bug status to New
Sorry, I can't make a stack dump at this moment. I hope to have time in the next weeks. Would be nice if someone else had this problem too and could make this dump earlier...
Status: NEW → ASSIGNED
Mozilla won't crash for me on a glibc 2.1.2 system with a 111206 trunk build but Mozilla definitely refuses to POST to 127.0.0.1 although GET works. Is this some sort of misguided security feature?
Not being able to POST to 127.0.0.1 is a bug, but I am unable to reproduce it on a RH 7.0 system. Do you see any interesting messages in the console?
If you mean me, nothing at all happens; no messages, nothing. The server logs show no activity at all. If I use a proxy server, it's logs also show nothing. It seems to be specific to the string "127.0.0.1". Just in case localhost is treated specially, I added this line 127.0.0.1 me.local me to /etc/hosts and Mozilla posts to http://me.local/ and http://me/ just fine. I'll attach a test page.
I was going to report this bug. I have additional information. (Tests with M18 2000100722 and a CVS version in that last 48 hours.) The browser dies in as it goes through wallet wallet_IsFromCartman. Note the check PL_strncasecmp(host, "127.0.0.1", 9) == 0 leading into the code. Here is my trace: #0 0x403d2191 in free () at malloc.c:2952 #1 0x402a850f in PR_Free () at prmem.c:59 #2 0x40141e93 in nsMemoryImpl::Free () at nsMemoryImpl.cpp:438 #3 0x401426f5 in nsMemory::Free () at nsMemoryImpl.cpp:482 #4 0x4005e930 in Recycle () from /home/mlvanbie/software/mozilla/dist/bin/./libgkgfx.so #5 0x41e53ac0 in wallet_IsFromCartman (aURL=0x87961d8) at wallet.cpp:3629 #6 0x41e53ce7 in WLLT_OnSubmit () at wallet.cpp:3637 #7 0x41e45864 in nsWalletlibService::Notify () at nsWalletService.cpp:390 (gdb dies here, but that's my fault for not following the debugging instructions) I have /wallet.cpp/1.268/Tue Nov 14 14:26:40 2000// While I'm running SuSE and have the localhost problem, I can verify that these are not related. The 127.0.0.1 post problem affects MojoNation (also Zope, but that might just be due to my configuration).
I forgot to mention that the last debuggin message from Mozilla was *** Failure setting up Cartman!
To keep things simple, I filed bug 60362 on the POST failure only, not the crashing.
Ok, so this is a bug in the wallet code... it makes sense then that we are seeing it only in mozilla and not on the commercial netscape branch... PSM ("cartman") is not included in mozilla. ->morse@netscape.com
Assignee: darin → morse
Status: ASSIGNED → NEW
Component: Networking → Security: General
Can you give me some more details since I am unable to reproduce this. For starters, I'm a bit confused by the line numbers reported in the dump. The call to wallet_IsFromCartman within OnSubmit is on line 3554 in wallet.cpp version 1.268. But the dump is reporting it at line 3637. Furthermore, the next line number in the dump is in the IsFromCartman routine and gives a line number of 3629. So that should be eight lines prior to the IsFromCartman call. But going back eight lines from that call does not get me into the IsFromCartman routine -- instead it is still inside the OnSubmit routine. So I can't correlate the lines in the dump with actual lines in the source and therefore I can't say for sure where the crash is occuring. It must be on a Recycle statement according to the next line in the dump. There indeed are three Recycle in the IsFromCartman routine so I don't know which is the cuprit. One is for host, one for password, and one for secmanPassword. Could the reporter please insert some printf statement before and after each of these three Recycle statements so we can determine which one is the offender. Also, I wonder if we should be zeroing out these three variables when we declare them. Currently I am testing to see if I was able to get a valid host/password/secmandPassword by testing these for non-zero. Therefore another thing I would like to ask the reporter to try is to initialize these three items when they are declared and see if that fixes the problem. char* host = 0; char* password = 0; char* secmanPassword = 0; Thanks.
Summary: Crash while submitting a form from 127.0.0.1 → [x]Crash while submitting a form from 127.0.0.1
BTW, my educated guess is that it is the Recycle(host) that we are crashing on. I say that because the logic of the IsFromCartman routine is to test for the cartman URL (note that cartman uses the 127.0.0.1 url) and skip the bulk of the code in the routine if that is not true. In this case the form we are submitting to is not cartman so the only Recycle we should be executing is the one for host.
The 127.0.0.1 in the source is what got my attention too, and I would hope that NS_WITH_SERVICE would fail when there isn't a PSM, so it must be the Recycle(host) that is crashing... right?
Still... since the line numbers don't match up to the current source, and since you aren't able to repro this bug, I'm guessing that it was fixed somewhere along the line. Reporter: please re-verify this bug.
This crash was an exciting surprise. I found this code in http://127.0.0.1/xit/crtest2.htm: 1: <html> 2: <head><title>Let's crash again</title></head> 3: <body> 4: <form action="/cgi-bin/nothing.pl" method="put"> 5: <!-- Yes, nothing.pl doesn't have to exist and you can write "get" as 6: method as well. //--> 7: <input type="hidden" name="name" value="something"> 8: <input type="submit" value="Let's crash"> 9: </form> 10: </body> 11: </html> Look at line 4: method="put" - and it crashes anyway. ;o? I think, you could take method="crash" as well and it would work. (If I don't say anything else in the next five minutes, it really crashes.) It doesn't depend on what you send or how you send it. Mozilla has only the problem if I use the URL http://127.0.0.1/... .
I've forgotten the build id ;). Linux build 2000111821 still crashes. I'll try to compile Mozilla this evening.
I can't compile Mozilla. )-; ----- checking for libIDL - version >= 0.6.3... *** 'libIDL-config --version' returned 0.6.5, but libIDL (0.6.8) *** was found! If libIDL-config was correct, then it is best *** to remove the old version of LIBIDL. ----- YaST shows me for libIDL and libIDL-devel version 0.6.5. How the hell did ./configure get this strange number?
No more postings about libIDL here, I found this problem in netscape.public.mozilla.unix.
See bug 60819. That has to do with a crash when a cookie is set for 127.0.0.1. I suspect that these two bugs are related -- probably whatever is causing one is also responsible for the other.
Status: NEW → ASSIGNED
Sorry for the delay; I wasn't mailed the request for more information/tests, so nothing happened until I got bored. gdb does generate those numbers for the file that you have. Corrupting the stack is quite common on Linux x86 if bad data goes to free. I have a longer traceback, but you won't need it. Initializing the secmemPassword and password variables fixes the problem. (host is an argument to the function.) fprintf to stderr didn't show the problem ... the messages didn't appear until after the code was fixed. Thanks!
The reason you didn't get mailed the request for more information is because your name was not on the cc: list for this bug. I just added you so you will see my posting. Sorry, what I said above about it most-likely being "recycle(host)" was wrong. In re-reading the code I see that that is the one thing that is getting initialized (by the call to the GetHost as you just pointed out). And, contrary to what I said before, the other two recycles are not being skipped so they indeed must be the culprits. And this was born out by the test that you ran. So in essence the patch is to replace the following two lines char * password; char * secmanPassword; with these lines char * password = 0; char * secmanPassword = 0; I'll be making a big check-in of wallet.cpp (see bug 56644) as soon as I can get all the reviews, and I will include this change along with that check-in.
In fact, for safety I'll be initializing *host to 0 as well. So consider the total patch here to include the following change as well: - char * host; + char * host = 0;
In a private message, mlvanbie@thinkage.ca pointed out that the correct fix is to check for a return value when calling GetPassword (and GetHost as well). Of course he's right -- I was just trying to minimize the change. So let me fix this the right way. A better patch is: @@ -3606,32 +3609,28 @@ PRIVATE PRBool wallet_IsFromCartman(nsIURI* aURL) { PRBool retval = PR_FALSE; - char* host; - aURL->GetHost(&host); - if (host && PL_strncasecmp(host, "127.0.0.1", 9) == 0) { - /* submit is to server on local machine */ - nsresult res; - NS_WITH_SERVICE(nsISecurityManagerComponent, psm, PSM_COMPONENT_CONTRACTID, &res); - if (NS_SUCCEEDED(res)) { - char* password; - aURL->GetPassword(&password); - char* secmanPassword; - psm->GetPassword(&secmanPassword); - - if (password && secmanPassword && PL_strncasecmp(password, secmanPassword, 9) == 0) { - /* password for submit is cartman's password */ - retval = PR_TRUE; - } - if (password) { - Recycle(password); - } - if (secmanPassword) { - Recycle(secmanPassword); + char* host = 0; + if (NS_SUCCEEDED(aURL->GetHost(&host)) && host) { + if (PL_strncasecmp(host, "127.0.0.1", 9) == 0) { + /* submit is to server on local machine */ + nsresult res; + NS_WITH_SERVICE(nsISecurityManagerComponent, psm, PSM_COMPONENT_CONTRACTID, &res); + if (NS_SUCCEEDED(res)) { + char* password; + if (NS_SUCCEEDED(aURL->GetPassword(&password)) && password) { + char* secmanPassword; + if (NS_SUCCEEDED(psm->GetPassword(&secmanPassword)) && secmanPassword) { + if (PL_strncasecmp(password, secmanPassword, 9) == 0) { + /* password for submit is cartman's password */ + retval = PR_TRUE; + } + Recycle(secmanPassword); + } + Recycle(password); + } } } - } - if (host) { - Recycle(host); + Recycle(host); } return retval; }
Oops, ignore the "char* host=0" change in the patch above. That was left over from my original simple patch. So the line is back to "char* host". Here's the revised patch: @@ -3607,31 +3610,27 @@ wallet_IsFromCartman(nsIURI* aURL) { PRBool retval = PR_FALSE; char* host; - aURL->GetHost(&host); - if (host && PL_strncasecmp(host, "127.0.0.1", 9) == 0) { - /* submit is to server on local machine */ - nsresult res; - NS_WITH_SERVICE(nsISecurityManagerComponent, psm, PSM_COMPONENT_CONTRACTID, &res); - if (NS_SUCCEEDED(res)) { - char* password; - aURL->GetPassword(&password); - char* secmanPassword; - psm->GetPassword(&secmanPassword); - - if (password && secmanPassword && PL_strncasecmp(password, secmanPassword, 9) == 0) { - /* password for submit is cartman's password */ - retval = PR_TRUE; - } - if (password) { - Recycle(password); - } - if (secmanPassword) { - Recycle(secmanPassword); + if (NS_SUCCEEDED(aURL->GetHost(&host)) && host) { + if (PL_strncasecmp(host, "127.0.0.1", 9) == 0) { + /* submit is to server on local machine */ + nsresult res; + NS_WITH_SERVICE(nsISecurityManagerComponent, psm, PSM_COMPONENT_CONTRACTID, &res); + if (NS_SUCCEEDED(res)) { + char* password; + if (NS_SUCCEEDED(aURL->GetPassword(&password)) && password) { + char* secmanPassword; + if (NS_SUCCEEDED(psm->GetPassword(&secmanPassword)) && secmanPassword) { + if (PL_strncasecmp(password, secmanPassword, 9) == 0) { + /* password for submit is cartman's password */ + retval = PR_TRUE; + } + Recycle(secmanPassword); + } + Recycle(password); + } } } - } - if (host) { - Recycle(host); + Recycle(host); } return retval; }
OK, I'm stupid, but why does this patch continue to require PSM just to post to 127.0.0.1? It's a very well defined IP address and it's reserved for the loopback interface. I can't see any reason why it's deemed insecure.
No one ever said that posting to 127.0.0.1 requires PSM. The PSM architecture uses the loopback mechanism to access its user interface. The problem is that wallet needs to know when an access to 127.0.0.1 is for PSM's UI or for a real URL loading. That's what this routine is all about.
But PSM *is* necessary to POST to 127.0.0.1. That's part of this bug. That should not be. Mozilla does not control the IP address. Your patch doesn't seem to alter that; or am I mis-reading it?
No, PSM is *not* necessary to post to 127.0.0.1. If anybody said or implied that in this bug report, they were mistaken.
tenthumbs: back on 11/16 you said you filed bug 60362 about the POST problem, so let's leave that out of this one.
I tested the patch. Seems to work as well as just initializing the variables, except it is done right this time. Unfortunately, the POST attempt doesn't actually load the page. Works in lynx. Same problem with GET. POSTing to 127.0.01 and having nothing happen is Bug 60362. I did a grep of extensions/*/src/*.cpp and found this sort of thing in several files just for GetHost and GetPassword. The first file I found does the same thing with GetSpec, GetScheme and GetPath. Are these safe in general, with just GetPassword a problem? nsSecureBrowserUIImpl.cpp mentions Bug 55906 when doing the same sort of GetPassword thing that was a problem here. 55906 sounds similar to my new bug (but isn't the same), and is marked as a duplicate of 54966 (which superficially seems barely related). However, PSM gets mentioned again in the bug tracking. I don't have it installed yet, so I think that I should find out if it makes a difference.
Linux build 2000112206 still crashes with <form action="/cgi-bin/nothing.pl" method="crash"> <input type="hidden" name="name" value="something"> <input type="submit" value="Let's crash"> </form>
dveditz: You're quite right, but comments that should have been in 60362 wound up here and I decided to follow the data flow. Sorry.
Summary: [x]Crash while submitting a form from 127.0.0.1 → Crash while submitting a form from 127.0.0.1
Whiteboard: [rtm-] → [w][rtm-]
Whiteboard: [w][rtm-] → [z][rtm-]
Fix for bug 56644 has been checked in. That patch addresses the IsFromCartman bug described here. So the crash in the stacktrace presented in this bug report is now fixed. Closing this out. Please do not reopen unless that same crash (in IsFromCartman) is still occuring. If there is some other crash, or some other problem related to 127.0.0.1, please report that in a separate bug report. Thanks.
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
New problem: NOTHING happens while trying to submit a 127.0.0.1 form! The page with the form stays where it is! Hitting the submit button has the same result as hitting the stop button on an already loaded site. Seems not to be fixed at all... Verified for Linux build 2000120206 with my test page crtest2.htm and my CGI guestbook.
What you are describing is a different problem from the one addressed in this bug report. Please open a separate bug report on that.
Whiteboard: [z][rtm-] → [rtm-]
verified Linux rh6 2001010510
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: