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

Additional PHP path sanitization #1296

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

john-moore-levesque
Copy link

eb143e5 added PHP sanitization to one $path=trim($path), but there were three others, so this PR adds the same logic to those

# Make sure we don't have any path shenanigans going on
$path=str_replace(array("..","./"),"",$path);
# we don't need trailing slashes, and leading slashes are going to be invalid paths
$path=trim($path,"/");
$path=sanitize(trim($path,"/"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you sanitize this again after it was done four lines up?

@@ -120,7 +120,7 @@ function BuildFileList($returnjson=false,$path="."){
# Make sure we don't have any path shenanigans going on
$path=str_replace(array("..","./"),"",$path);
# we don't need trailing slashes, and leading slashes are going to be invalid paths
$path=trim($path,"/");
$path=sanitize(trim($path,"/"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above?

@wilpig
Copy link
Collaborator

wilpig commented Nov 5, 2021

http://dev.opendcim.org/configuration.php?dl=%22%27%3E%3CA+HREF%3D%22%2FWF_XSRF2027.html%22%3EInjected+Link%3C%2FA%3E

http://dev.opendcim.org/configuration.php?dl="/><svg/onload=alert(2023)%20width=100/>

http://dev.opendcim.org/configuration.php?fl=%22%27%3E%3CA+HREF%3D%22%2FWF_XSRF2027.html%22%3EInjected+Link%3C%2FA%3E

http://dev.opendcim.org/configuration.php?fl="/><svg/onload=alert(2023)%20width=100/>

Code injection test cases

@john-moore-levesque
Copy link
Author

The path is getting manipulated again after it’s sanitized. I wonder if it actually makes more sense to have the sanitization be the last thing that happens to the path instead of the first?

@samilliken
Copy link
Member

The santitize function is to protect against user injected crap. It's not being touched by the user after the first sanitize() call, therefore any subsequent calls to it are simply wasted cycles.

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.

3 participants