mirror of
https://github.com/telephone/LookingGlass.git
synced 2026-04-25 07:56:01 +03:00
[GH-ISSUE #37] Improve character escaping #27
Labels
No labels
enhancement
enhancement
enhancement
pull-request
v1
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/LookingGlass#27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @devicenull on GitHub (Jul 5, 2016).
Original GitHub issue: https://github.com/telephone/LookingGlass/issues/37
This method of escaping host IPs is pretty scary:
Per the PHP docs:
FILTER_SANITIZE_URL -> Remove all characters except letters, digits and $-_.+!*'(),{}|^~[]`<>#%";/?:@&=.
The majority of those characters have no business being in a domain name/IP address. I'd suggest checking the host against
FILTER_VALIDATE_IPinstead... if that doesn't validate, pass it to gethostbyname and use whatever that returns.Using
escapeshellarginstead of just'{$host}'would also be a good move.I don't see an obvious exploit for this, but that code really stands out to me as suspicious.
@telephone commented on GitHub (Jul 7, 2016):
If you look at
LookingGlass::validate()and it's subsidiary calls, you'll notice it's not that scary. The input is always validated against an IP or URL. The part that you've quoted (FILTER_SANITIZE_URL) is there as a backup.Using
escapeshellarg()isn't necessary, as I've already ensured single quotes are removed (in the section you've quoted). Instead of escaping single quotes viaescapeshellarg(), I'm simply removing them.