-
Notifications
You must be signed in to change notification settings - Fork 21
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
Scanning fails with error on directory structures with recursive symlinks #25
Comments
That exception is raised from another exception that should be an |
Thanks for replying. I'm not seeing any other error in the output before the exception I posted. Sent all debug output to a file, and grepped the file for |
The error would be written to stderr rather than stdout. Just to confirm, did you use something like It initially looks like a permission issue, but that should impact your |
My apologies--the I did use I agree that it felt like a permissions issue, but the fact that I can iterate through every single subdirectory without issue with a for loop seems to suggest otherwise. Each subdirectory within
|
What are the modes on each directory tier? I suspect there's a directory in that hierarchy that has read without execute. By creating a similar structure and setting the permissions for Directories should have the execute permission. Adding that should fix the scanning issue, assuming it's missing. |
Thanks for that idea. So normally everything within I tried setting everything to 777 just to test, and I got the exact same errors as reported above happening in the exact same place. I also want to reconfirm that every one of the homepage directories ( |
It sounds like the permissions should be OK, then. There aren't any additional permission controls like ACLs in place, are there? Is the user who is running Wordfence CLI the same as the owner of the directories? Can you confirm that |
No ACLs in place. I've been running the testing as the root user. We do use the apache module mpm_itk (http://mpm-itk.sesse.net/), and so Not being familiar with the wordfence code, it almost feels as if a buffer were getting filled up. Does that seem possible? |
If this issues occurs when running as Do you have the ability to run Python on this system? I've put together a test script with a simplified version of the file locator so hopefully we can actually capture the underlying error. import os
import sys
def search_directory(path: str):
contents = os.scandir(path)
for item in contents:
if item.is_dir():
yield from search_directory(item.path)
elif item.is_file():
yield item.path
def locate(path: str):
real_path = os.path.realpath(path)
if os.path.isdir(real_path):
for path in search_directory(real_path):
print(path)
else:
print(real_path)
path = sys.argv[1]
print(f'Base path: {path}')
locate(path=path) You can save this script to a file and then run the following: That should yield an |
To prevent the need for debugging such issues outside of the Wordfence CLI tool in the future, I've added #31 to the next milestone. |
Perfect! That produced the full text of the
This is the full error output:
Removing the Thank you for that! Your patience and support is very much appreciated :) |
Thanks for working with me to diagnose that! We need to handle this better within Wordfence CLI. I'm going to leave this issue open for now and update it to reflect that we need additional handling for recursive symlinks. |
Added detection for recursive symlinks
Created 5 symlinks to test a variety of scenarios, and verified error no longer occurs, and instead a notification appears in the output as "Recursive symlink detected at /path/being/scanned" for each occurrence:
Symlinks that are not recursive do not present a warning and scan without error. Additional testing included a variety of file paths with both stdout and progress output, adding in options that include number of workers, file types to include, large and small scale malware findings, debug, verbose, routing stderr to file, defining output-path, as root, as user, with and without allow-io-errors option. |
Hi all,
Just started testing the wordfence-cli on a server.
Server OS: debian 11.7
Wordfence version: 1.0.1
When I run
wordfence scan /var/www
, I see:If I enable debugging with
wordfence scan -d /var/www
, I see several thousand lines printed to the screen as wordfence-cli scans through the subdirectories. Eventually it exits with this message:Everytime it fails, it fails while processing a sub-directory within
/var/www
, let's call it/var/www/websites/
. If I runwordfence scan -d /var/www/websites
, I see the exact same Traceback as above.However, if we create a for loop to run wordfence-cli in each subdirectory under
/var/www/websites/
, such as withfor d in /var/www/webpages/*; do wordfence scan $d; done
, every single scan completes without error.Any thoughts? Anything else I can provide?
The text was updated successfully, but these errors were encountered: