Giter Site home page Giter Site logo

safetorun / safe_to_run Goto Github PK

View Code? Open in Web Editor NEW
37.0 1.0 0.0 75.33 MB

A library to help verify the security of your android application

Home Page: https://safetorun.com

License: Apache License 2.0

Kotlin 99.93% Shell 0.07%
security kotlin android androidsecurity devsecops mobile mobilesecurity securityascode

safe_to_run's People

Contributors

codacy-badger avatar dependabot[bot] avatar dllewellyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

safe_to_run's Issues

Backend storage & synch

Create the ability for data to be stored locally and sent in bulk to the backend server for analytics event

Improve debug detection

static boolean detect_threadCpuTimeNanos(){
long start = Debug.threadCpuTimeNanos();

for(int i=0; i<1000000; ++i)
continue;

long stop = Debug.threadCpuTimeNanos();

if(stop - start < 10000000) {
return false;
}
else {
return true;
}
}

Add feature for device binding

Prevent an app + its data from being copied and working correctly from one device to another

Can do this by using the android keystore to generate a signature and then verifying it on launch

Need to be able to store device IDs on device

We should ideally keep track of device IDs by creating a unique device ID for each user and storing it on device.

We should also look to allow someone to access the device ID from the public facing SDK.

Logging & Dry run

  • We should be able to allow logging of check failures so that we are able to either log to console for debugging purposes when a check fails (note: must make sure to disable for production deployments)
  • Or / and allow for remote logging to a server, particularly for failed intent / url / file checks so that developers can adjust their configurations to make sure they aren't too restrictive.
  • Also makes sense to allow for a 'dry-run' mode so that if developers are integrating safe to run they can safely deploy without suddenly breaking app functionality

Re-configure the blacklistedAppCheck

Allow for having a builder and configuration that looks like this:

safeToRun(
       blacklistedAppCheck {
              "com.test.app".add()
              rootApps.addAll()
       }
 )

Create app metadata

Capture device metadata to form part of the API call. Should include:

  • Version code
  • Package name
  • Version string

Intent verifier - shouldn't have a .addConfiguration() function

Currently to add a URL Configuration, you have to do this:

val extraIntent = intent.getParcelableExtra<Intent>("extra_intent")
        extraIntent?.verify(this) {

            urlConfiguration {
                "insecureapp.com".allowHost()
            }.addConfiguration()

            actionOnSuccess = {
                startActivity(extraIntent)
                finish()
            }

            actionOnFailure = {
                throw RuntimeException("Please don't hack my app")
            }
        }

Instead, it should just be added automatically by adding a URL configuration function to the builder. e.g. it should look like this:

extraIntent?.verify(this) {

            urlConfiguration {
                "insecureapp.com".allowHost()
            } 
}

Add ability to generate code from config

Allow generation of input verification code from a configuration file. This will allow input verification configuration to be validated at build time, but also allow us to change configuration remotely

Rotate backend secret key

Provide a mechanism for rotating the backend secret (ideally using a certificate) and also provide a way of exposing the public certificate to 3rd parties for verification on their own server

Verify file

Check for sensitive files that you might be accidentally egressing and also check for directory traversal that you might be downloading

Add a logging function which can be attached to safe to run - resilience

Add the ability for a function or interface to be attached to safe to run resilience which will allow us to log failures and successes - also add a default logger which logs to logcat.

  • Need to be attachable in some way to this: package com.safetorun.inline/safetorun.kt

Most likely the best way would be adding a function as a parameter - e.g.:

// Current 

inline fun safeToRun(
    safeToRunChecks: List<SafeToRunCheck>
)

// Add this:
inline fun safeToRun(
    logFunction : (Boolean) -> Unit,
    safeToRunChecks: List<SafeToRunCheck>
)

Need to do this in such a way that we actually have two functions so as not to break for existing users

False emulator trigger on Xiaomi

Some (or maybe all) Xiaomi devices have set Build.BOOTLOADER = "unknown"

because of that, every emulator check false triggers

these method are affected
banAvdEmulatorCheck()
banBluestacksEmulatorCheck()
banGenymotionEmulatorCheck()

Review intent verification

  • Intent verification could (and probably should) be reviewed to make it so that you can model what an intent should look like. For example:
intentVerificationBuilder {
  allowUnknownFields = false
  addDataVerification(...)
  actionVerification(..)
  addBundleVerification(parameterName = "") {
  }

  addIntentVerification(parameterName =   "") {
     intentVerification = intentVerificationBuilder { ... }
  }

  addStringVerification(parameterName = "file") {
      fileVerification =  //...
  }
 
  addStringVerification(parameterName = "url") {
     urlVerification = urlVerification {}
  }
}

Need to verify loads of different types, e.g. Int, Byte, IntArray, ByteArray etc

Add PIN input screen

Requires

  • A global object that can be called to ask 'is the user logged in'
  • A global object to log a user out
  • A way of creating a PIN for the first time
  • A way of storing said pin securely
  • A way of verifying the PIN for future
  • A callback that can be used to register for pin changes (i.e. has the user logged out)

Allow calling from react native

In order to allow safe to run functionality to run from react we can package & create a package that can be installed in a react native app and called from javascript.

Need to consider:

  • No-op for non-android apps (e.g. iOS)
  • Deployment to package manager
  • Automated testing

Create a function to capture device metadata & failures

Create a comprehensive function for capturing device metadata and potential failures.

Specifically, this should be the object to capturing data:

data class DeviceMetadata(buildInfo : Map<String, String>, rooted : Boolean, emulator : Boolean, signature:String, installOrigin:String, extraData : Map<String, String>) 

Build information would be populated by the Build class.

Extra data would be left empty by default, but allow people to populate with extra checks they make

Intent verifier - shouldn't have a .addConfiguration() function

Currently to add a URL Configuration, you have to do this:

val extraIntent = intent.getParcelableExtra<Intent>("extra_intent")
        extraIntent?.verify(this) {

            urlConfiguration {
                "insecureapp.com".allowHost()
            }.addConfiguration()

            actionOnSuccess = {
                startActivity(extraIntent)
                finish()
            }

            actionOnFailure = {
                throw RuntimeException("Please don't hack my app")
            }
        }

Instead, it should just be added automatically by adding a URL configuration function to the builder. e.g. it should look like this:

  extraIntent?.verify(this) {

            urlConfiguration {
                "insecureapp.com".allowHost()
            } 
}

Improve authentication

We'll need to be able to differentiate between simple API key auth as would be provided from the app (e.g. a public API key) and users who need to perform extra queries - e.g. because they want to be able to query for a list of device information(s) etc

Clunky os check syntax

The os check syntax is slightly clunky it might make more sense for conditional builder to be re written

Kotlin Compiler plugin

Allow Annotation to provide check before a function is executed.

This means

  • creating an Annotation most likely one per check type e.g. Intent check, URL check, file check
  • Annotation takes a name eg the checker to use
  • write a kotlin Compiler plugin to parse those annotations
  • replace with a call to a function that checks against the configuration for that name

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.