Closed Bug 45565 Opened 26 years ago Closed 26 years ago

Make UA string customizable

Categories

(Core :: Networking, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: BenB, Assigned: BenB)

References

()

Details

Attachments

(2 files)

"Mozilla/5.0" is hardcoded. Read from prefs. Some users want to change this. Reading the whole beast from prefs would be even better. Patch will follow. Jud, can you review, please?
this piece of the UA string is intentionally hardcoded. You can't browse without that hardcoded string (modifications break the world). Could the value be changed programatically via JS in a web page if it were a pref?
> this piece of the UA string is intentionally hardcoded. You can't browse > without that hardcoded string (modifications break the world). Sorry, but this is nonsense. People use very freaky UA-strings (sat by various proxies). Even if some pages broke, this decision should be up to the user. There is enough demand for this choice. > Could the value be changed programatically via JS in a web page if it were a > pref? Webpage JS *should* not be able to set prefs - it would be a security problem in many other cases as well. Note that you can currently set e.g. the security part via pref.
Status: NEW → ASSIGNED
Target Milestone: --- → M17
Attached patch Fix — — Splinter Review
3 new prefs: general.useragent.[appname|appversion|override]. With the first two, you can change "Mozilla" and "5.0" (falling back to the previous hardcoded defaults, if they are not sat), with the last one you can override the whole useragent string at once, which allows to break out of the structure and even override the OS etc. (which can be a security *feature*, if used well).
Keywords: review
1. It ain't non-sense when modifying Mozilla/x.x results in dozens of emails from people complaining about how they can't visit site foo. 2. Proxies, spiders, agents and various clients indeed use many random UA strings. However, there's a reason 95% of the clients on the web hard code "Mozilla/x.x" and that's because there's a lot of content out there that won't service any other requests. 3. I've had this "discussion" a zillion times, and the same logic is always used. I agree that the entire string *should* be modifiable, but what worries me is someone cracking our JS security model somehow, putting up a page that changes this setting, then that browser becomes useless until the user figures out what went wrong. Maybe this is an unwaranted fear. actually, on that last note, I'm going to ask that we *not* make this change. If you (or someone else playing w/ this) change your agent and you starting getting rejections (of many forms) from content, you could very easily file a bug that is a result of your UA string being different, and someone (most often in networking) will spend a good hunk of time (I've spent days chasing UA string problems) chasing a phantom problem.
Cc'ing dbaron, who is user-agent owner for Mozilla, and waterson. Jud, I don't think your objection #3 is valid: if someone cracks our security code, many bad things can happen, but that doesn't mean we don't empower trusted scripts to do useful things. We do and should. I am not convinced a pref is the right way here at all. It's more a matter of compile-time branding than user preference, I think. If we could use #ifndef and #define to avoid hardwiring Mozilla/5.0 in a way that makes branders of the source have to muck with an otherwise readonly source file, that would win. /be
Posted to .netlib "Should the UA string be settable per pref?" <news://news.mozilla.org/3970C1EF.69BC94C9@bucksch.org>.
> I am not convinced a pref is the right way here at all. It's more a matter of > compile-time branding than user preference, I think. If we could use #ifndef > and #define to avoid hardwiring Mozilla/5.0 in a way that makes branders of > the source have to muck with an otherwise readonly source file, that would > win. I don't think, this is a problem. *All* Mozillas of this version propably should have "Mozilla/5.0" in the beginning, for the reasons valeski and the spec name. We have "vendor" fields for branding. But many *users* want to change the string, without compiling.
> But many *users* want to change the string, without compiling. First I've heard of this. I doubt Mom&Pop want to do any such thing. Can you tell me more about such users? *Why* do they want to change the beginning of the user-agent? /be
> I doubt Mom&Pop want to do any such thing. lol, agreed. > Can you tell me more about such users? *Why* do they want to change the > beginning of the user-agent? (Easiest ones first) - Change for the sake of it - "See, I'm cool. I can hack my browser." - Security: If a webserver admin knows details about my platform (e.g. the kernel version, as sent out for Unix), he can start a specific attack. - Many exploits involve writing of certain files, which are of course different across platforms. - Certain OS versions may have known bugs, e.g. the remote-root-exploit bug of the 2.2.14 kernel. - Privacy - I just may not want others to know my platform - I may use an usual combination and want to set it to a more usual string
(Mostly talking about the whole UA string, i.e. "general.useragent.override".)
> I may use an usual combination *un*usual (sorry for the spam.)
I want that setting, too :-)
You might want to change the user_agent because some websites don't like the browser version or OS. I have an online banking site that only likes Windows or MacOS browsers. It doesn't even like Opera unless you set it to spoof as netscape 4.73. Perhaps instead of fully customizable, there could be a few options known to work, such as the following prefs: Pretend to be Netscape 4.08 Pretend to be Netscape 4.73 Pretend to be MSIE 5.0 Pretend to be Netscape 3.04 Pretend to be a Windows browser Pretend to be a MacOS browser
So, what do we do now?
Having a general override for the whole string seems like it does have some uses for power users (as mentioned above), especially on uncommon platforms, and also maybe for our QA, if we want to test if a layout "bug" is really the site's bad browser-sniffing or test UA-string changes in advance. I don't see the value of having separate overrides for AppName and AppVersion, unless that would affect JS sniffing too. However, messing with the UA string should be "unsupported" for end-users (since we know a lot of things break if it's changed), and it shouldn't be possible to do so accidentally or for a malicious web page to do so. As far as the UA-string spec is concerned, I think all that matters is what the default is that ships with the browser. That's what most people will use. Furthermore, (almost) however that default is stored, it can be changed.
> I don't see the value of > having separate overrides for AppName and AppVersion I could remove that. > messing with the UA string should be "unsupported" for end-users Agreed.
I'll attach a new patch, which only adds the general.useragent.override prefs and leaves Mozilla/5.0 hardcoded. Changing SUMMARY to reflect this.
Summary: Read AppName/AppVersion for useragent-string from prefs → Make UA string customizable
Some websites will not allow Mozilla/5.0. I know, my online banking site won't allow netscape 4.08 for linux, only windows. Perhaps 4.7 or 4.08 should be allowed as well.
Ben, looks good to me except that now rv is uselessly initialized to NS_OK, then immediately set to the result of CopyCharPref. I would remove the useless NS_OK initializer. Anyone else want to give this an r=? I'll say a= once the NS_OK nit is picked. /be
Brendan, the needless initialization is preexistant, but I'll remove it before I check in. Please see <http://www.bucksch.org/1/projects/mozilla/review.html> before reviewing.
gagan, would you review, please?
Jud should review this.
ugh. user agents suck. we're about to rewrite all this stuff and I'd like to deal w/ this kind of customization then/after that.
Rewrite what? Anyway, can't we just get this in now, and when you rewrite, you just maintain that (override) functionality? I'd like to - have this from my plate and - make sure this is in the product
the ua stuff is being overhauled. r=valeski.
> the ua stuff is being overhauled. Can you cc me in that bug, please? > r=valeski Thanks
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Target Milestone: M17 → M18
I realize the fix is already in, but since there seems to be quite a bit of disagreement on its usefulness, I just thought I would mention another posible use for it: To spoof other browsers. For example, there is quite a bit of content out there that is unviewable with anything other than IE. This is a long-running problem, but I blame it on IE in the first place, which started this mess by pretending to be Mozilla, changing its UA string to "Mozilla/x.x (compatible: MSIE x.x)", to work around sites in existence at the time that were looking at the UA string and refusing to serve content to IE. With a pref for the UA string, this could be solved. BTW, for a GOOD example of it in action, check out the UA-string spoofing option at the web page backward compatibility viewer, now playing at an URL near you: http://www.delorie.com/web/wpbcv.html
VERIFIED: I'd like to see further documentation of these preferences, but this feature is clearly in and used all the time. I compared logs of user agent to the relevant contents of "$INSTALL/defaults/pref/*" "Mozilla/5.0 (X11; U; Linux 2.2.16-22smp i686; en-US; rv:0.9) Gecko/20010505" all.js:pref("general.useragent.locale", "chrome://navigator/locale/navigator.properties"); all.js:pref("general.useragent.misc", "rv:0.9"); security-prefs.js:pref("general.useragent.security", "U"); "Mozilla/5.0 (X11; U; Linux 2.2.16-22smp i686; en-US; rv:0.8.1+) Gecko/20010416 Netscape6/6.5b0" all.js:pref("general.useragent.locale", "chrome://navigator/locale/navigator.properties"); all.js:pref("general.useragent.misc", "rv:0.8.1+"); all-ns.js:pref("general.useragent.vendor", "Netscape6"); all-ns.js:pref("general.useragent.vendorSub", "6.5b0"); security-prefs.js:pref("general.useragent.security", "U");
Status: RESOLVED → VERIFIED
QA Contact: tever → benc
benc, the new pref here is general.useragent.override. Please test *that*.
Bug 46029 is about a GUI for this pref.
Adding mostfreq keyword for the many bugs that are dupped against bug 46029.
Keywords: mostfreq
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: