Skip to content

Allow colon in socket path - #1305

Closed
magnusvin wants to merge 1 commit into
vrana:masterfrom
magnusvin:allow-colon-in-socket-path
Closed

Allow colon in socket path#1305
magnusvin wants to merge 1 commit into
vrana:masterfrom
magnusvin:allow-colon-in-socket-path

Conversation

@magnusvin

Copy link
Copy Markdown
Contributor

Fixes a regression introduced by 3faf095 (GHSA-58cq-mgw2-38m5) that made host_port() reject server strings where the socket/port portion contains a colon, causing a spurious "Invalid server." error. This breaks connecting via socket paths that legitimately contain colons, e.g.:
:/cloudsql/project:region:instance (Google Cloud SQL Unix socket)
:/var/www/mysql.sock

Changes
adminer/include/auth.inc.php: allow : in the validated port/socket pattern ([-\w./]*[-\w.:/]*), matching what host_port() can return.
adminer/include/functions.inc.php: host_port()'s port/socket capture group changed from [^:].+ to [^:].*. The .+ required at least 2 characters after the colon, so a single-character port (e.g. localhost:5) failed to match and was returned unsplit as the host instead of being split into (host, port). Since the host pattern permits colons, this let a single-character port slip past the privileged-port check (< 1024) entirely, as the port value it checks was left empty. .* restores splitting for 1-character ports/sockets too.

@vrana

vrana commented Jul 20, 2026

Copy link
Copy Markdown
Owner

This would parse 2001:0db8:0:0:0:0:1428:57ab as host 2001 and port 0db8:0:0:0:0:1428:57ab.

@magnusvin
magnusvin force-pushed the allow-colon-in-socket-path branch from dacb0e1 to 4ff6e67 Compare July 20, 2026 14:44
@magnusvin

Copy link
Copy Markdown
Contributor Author

Now is the change from ~^(\[(.+)]|([^:]*)):([^:]+)$~ to ~^(\[(.+)]|([^:]*)):(\d+|/.+)$~, short from ([^:]+) to (\d+|/.+).

Tested these values:

Server Host Port
localhost:/var/www/mysql.sock localhost /var/www/mysql.sock
localhost:3306 localhost 3306
[::1]:/var/www/mysql.sock ::1 /var/www/mysql.sock
[::1]:3306 ::1 3306
db-master:3306 db-master 3306
:/var/www/mysql.sock /var/www/mysql.sock
:/cloudsql/project:region:instance /cloudsql/project:region:instance
[2001:0db8:0:0:0:0:1428:57ab]:/var/www/mysql.sock 2001:0db8:0:0:0:0:1428:57ab /var/www/mysql.sock
[2001:0db8:0:0:0:0:1428:57ab]:/cloudsql/project:region:instance 2001:0db8:0:0:0:0:1428:57ab /cloudsql/project:region:instance
[2001:0db8:0:0:0:0:1428:1428]:/cloudsql/project:region:instance 2001:0db8:0:0:0:0:1428:1428 /cloudsql/project:region:instance
[2001:0db8:0:0:0:0:1428:1428]:3306 2001:0db8:0:0:0:0:1428:1428 3306
[2001:0db8:0:0:0:0:1428:57ab]:3306 2001:0db8:0:0:0:0:1428:57ab 3306

@vrana

vrana commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Thank you, I will fix it together with other problems this caused.

@vrana vrana closed this Jul 20, 2026
peterpp added a commit to adminneo-org/adminneo that referenced this pull request Jul 20, 2026
peterpp pushed a commit to adminneo-org/adminneo that referenced this pull request Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants