Skip to content

Commit 92190e5

Browse files
Add docs
1 parent 706858e commit 92190e5

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto">
5+
6+
<!-- BAD: This password field uses the `text` input type, which allows the input to be saved to the keyboard cache. -->
7+
<EditText
8+
android:id="@+id/password_bad"
9+
android:inputType="text"/>
10+
11+
<!-- GOOD: This password field uses the `textPassword` input type, which ensures that the input is not saved to the keyboard cache. -->
12+
<EditText
13+
android:id="@+id/password_good"
14+
android:inputType="textPassword"/>
15+
</LinearLayout>
Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1-
todo
1+
<!DOCTYPE qhelp PUBLIC
2+
"-//Semmle//qhelp//EN"
3+
"qhelp.dtd">
4+
<qhelp>
5+
6+
<overview>
7+
<p>When a user enters information to a text input field on an Android application, then by default their input is saved to a keyboard cache,
8+
which provides autocomplete suggestions and predictions. If the input field is expected to contain sensitive information, such as a password or banking details,
9+
this sensitive data may be leaked to other applications via the keyboard cache.</p>
10+
11+
</overview>
12+
<recommendation>
13+
14+
<p>For input fields expected to accept sensitive information, an input type such as <code>"textNoSuggestions"</code> (or <code>"textPassword"</code> for a password)
15+
should be used to ensure that the input does not get stored in the keyboard cache.</p>
16+
17+
</recommendation>
18+
<example>
19+
20+
<p>In the following example, the field labeled BAD could allow the password to be saved to the keyboard cache;
21+
whereas the field labeled GOOD uses the <code>"textPassword"</code> input type, which ensures that it is not.</p>
22+
23+
<sample src="Example.xml" />
24+
25+
</example>
26+
<references>
27+
28+
<li>
29+
OWASP Mobile Application Security Testing Guie: <a href="https://github.com/OWASP/owasp-mastg/blob/b7a93a2e5e0557cc9a12e55fc3f6675f6986bb86/Document/0x05d-Testing-Data-Storage.md#determining-whether-the-keyboard-cache-is-disabled-for-text-input-fields-mstg-storage-5">Determining Whether the Keyboard Cache Is Disabled for Text Input Fields</a>.
30+
</li>
31+
<li>
32+
Android Developers: <a href="https://developer.android.com/reference/android/widget/TextView#attr_android:inputType"> <code>android:inputType</code> attribute documentation.
33+
<li>
34+
35+
</references>
36+
</qhelp>

java/ql/src/Security/CWE/CWE-524/SensitiveKeyboardCache.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* @description Sensitive information should not be saved to the keyboard cache.
44
* @kind problem
55
* @problem.severity warning
6-
* @id java/android/debuggable-attribute-enabled
6+
* @id java/android/sensetive-keyboard-cache
77
* @tags security
8-
* external/cwe/cwe-489
8+
* external/cwe/cwe-524
99
* @precision high
1010
*/
1111

0 commit comments

Comments
 (0)