Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid hidden Joomla files/folders sometimes fail the filter #51

Open
GeraintEdwards opened this issue Dec 16, 2021 · 1 comment
Open

Comments

@GeraintEdwards
Copy link

Steps to reproduce the issue

  1. Apply the path filter to the path

/var/www/vhosts/website-net/subdomain-website-net/._hiddenTemp

  1. Apply the path filter to the path

/var/www/vhosts/website.net/subdomain.website.net/._hiddenTemp

Expected result

  1. Should return the cleaned path

/var/www/vhosts/website-net/subdomain-website-net/._hiddenTemp

  1. Should return the cleaned path

/var/www/vhosts/website.net/subdomain.website.net/._hiddenTemp

Actual result

  1. Returns the path

/var/www/vhosts/website-net/subdomain-website-net/._hiddenTemp

  1. Returns an empty path

``

Additional comments

Plesk servers use the domain/subdomain pattern 2 so this is a live issue.

Additionally the use of hidden files/folders is a valid and security enhancing use case - setting the Joomla tmp or log directory to a hidden *nix folder is a good thing. Also can be used to install a hidden Joomla installation in an obscure and hidden sub-folder of a live site.

@GeraintEdwards
Copy link
Author

Took me a little while to figure out why case 1 was ok but not case 2.

The regexp pattern being used is

$linuxPattern = '/^[A-Za-z0-9_\/-]+[A-Za-z0-9_\.-]*([\\\\\/]+[A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/';

The first part of this matches all characters up to the first period
[A-Za-z0-9_\/-]+

The second part then matches up to the next 'slash'
[A-Za-z0-9_\.-]*

So the string
/var/www/vhosts/website-net/subdomain-website-net/._hiddenTemp
is covered all the way by the first 2 parts and the hidden folder is allowed.

But the string
/var/www/vhosts/website.net/subdomain.website.net/._hiddenTemp
skips to the thirs part of the regex pattern at the first slash after the first period in website.net

Then the third block won't allow the hidden prefix :(

Examining this in more detail this filter doesn't clean double dotted paths - don't know if this was intentional

/var/www/vhosts/mainsite/../another.website.net/something -> cleans to
/var/www/vhosts/mainsite/../another.website.net/something

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

No branches or pull requests

1 participant