Git Product home page Git Product logo

Comments (6)

russellhancox avatar russellhancox commented on April 28, 2024

I'm in the middle of adding file-modification logging right now (see master...russellhancox:master).

What sort of filtering are you interested in doing?

from santa.

x43x61x69 avatar x43x61x69 commented on April 28, 2024

As someone found out that the dynamic library injection could bypass the Santa detection as they are not considered within KAUTH_SCOPE_VNODE, they could still be catched if we use the FILEOP scope with KAUTH_FILEOP_OPEN. (Which will cause deadlock according to Apple TN2127.)

I tried to feed the message from the fileop_scope_callback() into GetResponse() like the VNODE callback does. The system will freeze if I do this, tho KAUTH_FILEOP_CLOSE with KAUTH_FILEOP_CLOSE_MODIFIED would not cause this issue, but wouldn't get the result I wanted. (Catch the dylib as dyld still need to read the file before it can be load into the main binary.)

Hope my English is understandable. :p

from santa.

russellhancox avatar russellhancox commented on April 28, 2024

Gotcha. The problem with that is the result of the Fileop callback is always ignored, so you can't block a file that way and blocking fileop while waiting for a result in userspace is almost guaranteed to deadlock anyway, as TN2127 says.

On top of that, for the specific issue of whitelisting dylib's, there isn't a way of differentiating between an open by dyld and an open by say "cp" or "mv" or "installer". If you just wanted to log (rather than block) dylib opens it might be possible to put something in fileop_open that reads the first page of the file in kernel space and checks its file type and logs the name and pid of the opening process.

from santa.

x43x61x69 avatar x43x61x69 commented on April 28, 2024

Thanks for the reply. I did understand that we can't block the dylib, but we can "fix" (either patch it back or damage) it so it can't be load by dyld. (At least that's what Apple told us.) As we tapped on the vnode scope, we will know if there's a script running to do the injection or via sh etc. We can also get the script file path so if it's a known malicious script/dylib sha256, even that we can't stop it from running, we can still guess what files has been modified after it started, better than nothing.

I'm able to log the path of the dylib via KAUTH_FILEOP_OPEN, but seems sending everything to the daemon is way too much work for it to handle. I haven't try to do the file type directly in the kernel space tho, might be a better way as it's a bit better than let the daemon to do all the work. Will try that later.

Is Santa going to implement the "on access" scanning feature in the future? Or it's for executable only?

from santa.

russellhancox avatar russellhancox commented on April 28, 2024

It's for executables only.

from santa.

x43x61x69 avatar x43x61x69 commented on April 28, 2024

OK, thanks again. :)

I'll close this issue now.

from santa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.