GithubHelp home page GithubHelp logo

Comments (9)

arthaud avatar arthaud commented on April 19, 2024 1

Apparently, this generates a CHECK_CAST v1, Ljava/lang/String; in Dex. We currently ignore those, so there is no way to differentiate these, unfortunately.

from mariana-trench.

yuhshin-oss avatar yuhshin-oss commented on April 19, 2024

If I'm understanding the question correctly, a propagation model like this might be what you are looking for:
https://github.com/facebook/mariana-trench/blob/main/configuration/model-generators/propagations/IntentDataFeatureGenerator.json#L3-L22

This specifies that any taint that flows through the first argument of Intent.setData() will taint the this object and a feature called "via-intent-data" will be added to the flow.

And if I've misunderstood the question, could you provide code examples to go along with it just for clarification? Thanks!

from mariana-trench.

chuayupeng avatar chuayupeng commented on April 19, 2024

Hi @yuhshin-oss, I was thinking more along the lines of detecting something specific like this:

(Intent) extraIntent = getIntent().getParcelableExtra("Extra_Intent")

while excluding instances like this:

(String) extraString = getIntent().getExtras("String")

when my initial source is aimed at getParcelableExtra or getExtras.

Basically, something that would allow me the ability to stop the flow and deem it as a false positive if it was data casted into a class that I do not want.

from mariana-trench.

chuayupeng avatar chuayupeng commented on April 19, 2024

@yuhshin-oss this might be a bit out of scope I realise, but would like to know how to ensure that taint is propogated only through specific data type castings like above, but unsure of how to write it out

from mariana-trench.

yuhshin-oss avatar yuhshin-oss commented on April 19, 2024

Hi @chuayupeng, thanks for the example! Assuming the extraString in the example is the API call like the following:

var extraString = getIntent().getExtras().getString("test");

This type of casting is done explicitly with Bundle (or BaseBundle)'s get[Type](...) methods. This means that you can define models on the methods directly. In this case, adding a propagation feature like "via-bundle-getString" on the flow from "this (Argument(0))" to "return" of BaseBundle.getString() could help. Taint will still be propagated, but any issues found will contain the feature and can be filtered out. This would look something like:

{
  "find": "methods",
  "where": [
    {
      "constraint": "signature",
      "pattern": "Landroid/os/BaseBundle;.getString:(Ljava/lang/String;)Ljava/lang/String;"
    }
  ],
  "model": {
    "propagations": [
      {
        "input": "Argument(0)",
        "output": "Return",
        "features": [
          "via-bundle-getString"
        ]
      }
    ]
  }
}

from mariana-trench.

chuayupeng avatar chuayupeng commented on April 19, 2024

Hi @yuhshin-oss, what if the data casting is done like this?

(String) extraString = ...

That way, there is no method invocation, so was unsure of how to detect for cases like this

from mariana-trench.

arthaud avatar arthaud commented on April 19, 2024

Could you give another example? (String) is not valid on the left hand side of an assignment.

from mariana-trench.

chuayupeng avatar chuayupeng commented on April 19, 2024

Hi @arthaud,

I want to differentiate between these 2 lines of code, so I can reduce false positives when detecting intent redirections. Is there any way to detect what the data is casted into?

Intent extraIntent = (Intent) intent.getExtras("...");

and

String extraString = (String) intent.getExtras("...");

from mariana-trench.

arthaud avatar arthaud commented on April 19, 2024

That should be solved with a87023d

from mariana-trench.

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.