2

I am having a small .NET console application that the user launches on its local machine, passing a path argument to which the application is writing a file.

Can this be considered a path traversal vulnerability?

I was thinking this is not a real vulnerability that can be exploited since the application is launched by the user supplying a path. Won't this be having the user's permissions?

    2 Answers 2

    4

    Correct, at least in that use case. Path traversal, and all other forms of unsafe input, require that the client (source of the input, be it a user, web browser, etc.) want privileges that the server (thing that processes the input, could be a literal web / database server but also things like a driver or RPC service, or even another user on the same service) has. For a local app - unless the caller is sandboxed (and your app somehow isn't) - that's not the case; you have the same privileges as any software running under your account.

    However, it could become a problem in the future. Maybe somebody sets up a webapp that invokes your native app. Or some privileged service consumes an untrusted user's input and passes it to your code (which is now running with the service's privileges). As such, it's generally a good idea to remove any obvious attack vectors. That's also good practice for writing any kind of client-server system, which are everywhere now.

      -3

      Personally, I consider this a valid vulnerability, but the risk is significantly reduced due to the lack of impact.

      Some people will say it's not a vulnerability, but is a non-compliance with best practice.

      Either way, most people would recommend this be fixed.

      There is no universal consensus on the definition of "vulnerability" and for some people's definition you need a material impact, while for others it's sufficient to have a violation of expected behaviour that could potentially have a security impact.

      There are a number of MS command line tools vulnerable to deserialization flaws. Historically, this was considered not a vulnerability as you couldn't cross a security boundary. However, more recently, these have resurfaced as techniques that red teamers (and potentially, malicious attackers) use to bypass EDR.

      8
      • 3
        Not only this is not a vulnerability but it is also compliant with a best practice. The C# app runs in the context of the user and it's perfectly fine to have the user specify the output directory. Unless you want to say that software like PostgreSQL, Kafka, MinIO, 7z and similar are all vulnerable because they let the user run them with a specific data/output directory. Also, living-off-the-land doesn't mean the software used is vulnerable, just that once an user is impersonated, it's hard to stop attacks.CommentedSep 20, 2024 at 15:18
      • @MargaretBloom - The difference with software like PostgreSQL is that it's clear you're specifying a full path. In this example, it sounds like the user is specifying a file and it's unexpected they can break out of the directory.
        – paj28
        CommentedSep 20, 2024 at 16:53
      • I don't get it. If the user already has access to the specified path, what difference does it make if they use this script to write a file there?CommentedSep 20, 2024 at 19:28
      • @JimmyJames - you might allow access to the command in the belief it restricted users to a particular path, but due to directory traversal they can break out. I've been able to exploit similar to escalate from a restricted UI to command prompt.
        – paj28
        CommentedSep 20, 2024 at 19:49
      • @paj28 But the user can just write to the path without the script using other means. The script isn't giving them any access they didn't already have anyway.CommentedSep 20, 2024 at 19:51

      You must log in to answer this question.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.