GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Java: Query to detect cleartext storage of sensitive information using Android SharedPreferences by luchua-bc · Pull Request #4675 · github/codeql

Conversation

@luchua-bc

@luchua-bc luchua-bc commented Nov 16, 2020

Copy link
Copy Markdown
Contributor

SharedPreferences is an Android API that stores application preferences using simple sets of data values. Almost every Android application uses this API. It allows to easily save, alter, and retrieve the values stored in SharedPreferences.

However, sensitive information shall not be saved in cleartext. Otherwise it can be accessed by any process or user on rooted devices, or can be disclosed through chained vulnerabilities e.g. unexpected access to its private storage through exposed components.

This query detects storage of sensitive information in cleartext using SharedPreferences on Android devices.

Please consider to merge the PR. Thanks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@luchua-bc
Query for cleartext storage using Android SharedPreferences
0bd6255
@luchua-bc
luchua-bc requested review from a team and felicitymay as code owners November 16, 2020 17:27
@github-actions github-actions Bot added documentation Java labels Nov 16, 2020
@luchua-bc luchua-bc changed the title Query for cleartext storage using Android SharedPreferences Java: Query for cleartext storage using Android SharedPreferences Nov 16, 2020
@luchua-bc luchua-bc changed the title Java: Query for cleartext storage using Android SharedPreferences Java: Query to detect cleartext storage of sensitive information using Android SharedPreferences Nov 16, 2020
@luchua-bc luchua-bc mentioned this pull request Nov 16, 2020
[Java] CWE-312: Query to detect cleartext storage of sensitive information using Android SharedPreferences github/securitylab#205
Closed
1 task done
Marcono1234
Marcono1234 reviewed Nov 17, 2020
View reviewed changes
Comment thread java/ql/src/Security/CWE/CWE-312/ClearTextStorageSharedPrefs.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-312/ClearTextStorageSharedPrefs.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-312/ClearTextStorageSharedPrefs.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-312/ClearTextStorageSharedPrefs.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc
Format the source code and update qldoc
85434ca
@smowton smowton self-assigned this Nov 19, 2020
smowton
smowton reviewed Nov 19, 2020
View reviewed changes

@smowton smowton left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are in experimental but the query itself is not?

Also check my understanding: the reason we can't simply say a setter call against a SharedPreferences.Editor is a sink is because we need to know that this instance of SharedPreferences is specifically not an EncryptedSharedPreferences, which is a subclass that uses the same Editor?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread java/ql/src/Security/CWE/CWE-312/SensitiveStorage.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc
Move to query-test folder and update qldoc
a311462
@luchua-bc

luchua-bc commented Nov 19, 2020

Copy link
Copy Markdown
Contributor Author

Thanks @smowton for reviewing this PR.

Yes, your understanding is correct. We need to know that this instance of SharedPreferences is specifically not an EncryptedSharedPreferences, which is a subclass that uses the same Editor.

Although there is no existing tests folder java/ql/test/query-tests/security/CWE-312/, I've created one and moved the tests from experimental since the query itself is integrated into existing CWE-312 queries.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

smowton
smowton reviewed Nov 24, 2020
View reviewed changes

@smowton smowton left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions, many of which are perhaps best answered with negative tests (i.e. tests that show the relevant vulnerability, but the query cannot detect) -- what are this query's restrictions? Where can it tolerate arbitrary dataflow, and where only local dataflow or no intermediate flow at all?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread java/ql/src/Security/CWE/CWE-312/ClearTextStorageSharedPrefs.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-312/ClearTextStorageSharedPrefs.qhelp Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-312/SensitiveStorage.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-312/SensitiveStorage.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/Security/CWE/CWE-312/SensitiveStorage.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc
Enhance the query and add more test cases
a491604
smowton
smowton reviewed Nov 25, 2020
View reviewed changes

@smowton smowton left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could live in experimental, which will make the review process much easier -- as far as I can tell the only shared code with the existing SensitiveStorage file is your use of the SensitiveExpr class, which is already public so you should be able to use it from experimental?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread java/ql/src/Security/CWE/CWE-312/SensitiveStorage.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

luchua-bc added 2 commits November 26, 2020 17:09
@luchua-bc
Move to experimental and update qldoc
7ad031c
@luchua-bc
Add comments about how the future promotion should go
a83ddd6
@felicitymay
felicitymay removed their request for review November 27, 2020 09:00
@smowton

smowton commented Nov 27, 2020

Copy link
Copy Markdown
Contributor

I've started an evaluation of this -- one problem I noticed doing so: the @kind is currently path-problem, but the top-level select does not pick a source-sink pair. Either change @kind to problem, or decide on a path you want the query to show.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc
Change kind to problem
ad0ac5b
@luchua-bc

luchua-bc commented Nov 27, 2020

Copy link
Copy Markdown
Contributor Author

I've changed the @kind tag of the query back to problem, please continue to evaluate.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aschackmull
aschackmull reviewed Jan 6, 2021
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-312/CleartextStorageSharedPrefs.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

aschackmull
aschackmull reviewed Jan 6, 2021
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-312/CleartextStorageSharedPrefs.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

aschackmull
aschackmull reviewed Jan 6, 2021
View reviewed changes
Comment thread java/ql/src/experimental/Security/CWE/CWE-312/CleartextStorageSharedPrefs.ql Resolved

Uh oh!

There was an error while loading. Please reload this page.

aschackmull
aschackmull reviewed Jan 6, 2021
View reviewed changes
Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

luchua-bc added 2 commits January 6, 2021 16:21
@luchua-bc
Optimize the query
5690bf4
@luchua-bc
Update class/method names in the module
f13b881
aschackmull
aschackmull requested changes Jan 7, 2021
View reviewed changes
Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc
Revamp the library module
b54e5b1
aschackmull
aschackmull requested changes Jan 7, 2021
View reviewed changes

@aschackmull aschackmull left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more comments, otherwise it's looking good.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread java/ql/src/semmle/code/java/frameworks/android/SharedPreferences.qll Resolved

Uh oh!

There was an error while loading. Please reload this page.

@luchua-bc
Update qldoc
606d094
aschackmull
aschackmull approved these changes Jan 8, 2021
View reviewed changes
@aschackmull
aschackmull merged commit e5b4975 into github:main Jan 8, 2021
@luchua-bc
luchua-bc deleted the cleartext-storage-shared-prefs branch January 8, 2021 12:41
@atorralba atorralba mentioned this pull request Aug 11, 2021
Java: Promote Cleartext storage of sensitive information using SharedPreferences from experimental #6468
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@aschackmull aschackmull aschackmull approved these changes
+2 more reviewers
@smowton smowton smowton left review comments
@Marcono1234 Marcono1234 Marcono1234 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@smowton smowton

Labels

documentation Java

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@luchua-bc @smowton @Marcono1234 @aschackmull
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.