Closed Bug 1853203 Opened 2 years ago Closed 2 years ago

Support non-ASCII username/password for socks proxy

Categories

(Core :: Networking, defect, P2)

defect

Tracking

()

RESOLVED FIXED
119 Branch
Tracking Status
firefox119 --- fixed

People

(Reporter: jackyzy823, Assigned: jackyzy823)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 file)

​​### Basic information

Background:

https://github.com/foxyproxy/firefox-extension/issues/212

Steps to Reproduce:

  1. Add a user in linux system , change it's password to non-ASCII chars.
  2. Configure a dante socks proxy
  3. Install Addon FoxyProxy and configure proxy to dante socks proxy with user and its passowrd
  4. use socat as mitm to observe socks5 traffic.

Expected Results:

Proxy works, webpage opened.

Actual Results:

Proxy refused to connect due to wrong password.


Some analysis:
https://github.com/foxyproxy/firefox-extension/issues/212#issuecomment-1719690377

Some further digging:

After this line https://searchfox.org/mozilla-central/source/toolkit/components/extensions/ProxyChannelFilter.sys.mjs#232 , the password in proxyInfo is changed from "你好" to "`}"

I guess that when passing from JavaScript to c , password (in type ACString) is treat as narrow string , but underlying wide string.

I just do a test , set host to "你好" in foxy and then proxyInfo.host is just the same , because its type is AUTF8String so the JavaScript to c conversion is correct.

Ref https://searchfox.org/mozilla-central/source/netwerk/base/nsIProtocolProxyService.idl#194

Ref https://firefox-source-docs.mozilla.org/xpcom/stringguide.html

Not sure if changing idl will fix this "https://searchfox.org/mozilla-central/source/`__GENERATED__`/dist/include/nsIProtocolProxyService.h#102-103"

/* nsIProxyInfo newProxyInfoWithAuth (in ACString aType, in AUTF8String aHost, in long aPort, in ACString aUsername, in ACString aPassword, in ACString aProxyAuthorizationHeader, in ACString aConnectionIsolationKey, in unsigned long aFlags, in unsigned long aFailoverTimeout, in nsIProxyInfo aFailoverProxy); */
NS_IMETHOD NewProxyInfoWithAuth(const nsACString& aType, const nsACString& aHost, int32_t aPort, const nsACString& aUsername, const nsACString& aPassword, const nsACString& aProxyAuthorizationHeader, const nsACString& aConnectionIsolationKey, uint32_t aFlags, uint32_t aFailoverTimeout, nsIProxyInfo *aFailoverProxy, nsIProxyInfo **_retval) = 0;

in idl host is AUTF8String , but in c definition it is also nsACString.

So i guess change username/password in idl from ACString to AUTF8String would help ?


I tested a build of firefox with changing username/password in idl from ACString to AUTF8String and it works.


Example dante conf file /etc/sockd.conf

socksmethod: username
clientmethod: none

user.privileged: root
user.unprivileged: root

internal: 0.0.0.0 port = 8888
external: ens33

client pass {
        from: 0.0.0.0/0 to: 0.0.0.0/0
}


socks pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
}

run dante with sudo sockd
socat mitm: socat -x -v -d TCP4-LISTEN:6666,fork,reuseaddr TCP4:127.0.0.1:8888
configure foxyyproxy to socks5 , host: 127.0.0.1 port 6666

Assignee: nobody → jackyzy823
Status: NEW → ASSIGNED

Thank you for the patch.

Severity: -- → S3
Priority: -- → P2
Whiteboard: [necko-triaged]
Pushed by valentin.gosu@gmail.com: https://hg.mozilla.org/integration/autoland/rev/b85ea53114f7 Allow non-ASCII string in username/password of proxy info. r=necko-reviewers,valentin
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 119 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: