Skip to content

Commit 8d20162

Browse files
Add documentation
1 parent aa78050 commit 8d20162

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TextView pwView = getViewById(R.id.pw_text);
2+
pwView.setText("Your password is: " + password);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE qhelp PUBLIC
2+
"-//Semmle//qhelp//EN"
3+
"qhelp.dtd">
4+
<qhelp>
5+
<overview>
6+
<p>
7+
Sensitive information such as passwords should not be displayed in UI components unless explicitly required, to mitigate shoulder-surfing attacks.
8+
</p>
9+
</overview>
10+
11+
<recommendation>
12+
<p>
13+
For editable text fields containing sensitive information, the <code>inputType</code> should be set to <code>textPassword</code> or similar to ensure it is properly masked.
14+
Otherwise, sensitive data that is required to be displayed should be hidden by default, and only revealed based on an explicit user action.
15+
</p>
16+
</recommendation>
17+
18+
<example>
19+
<p>
20+
In the following (bad) case, sensitive information <code>password</code> is exposed to the <code>TextView</code>.
21+
</p>
22+
23+
<sample src="AndroidSensitiveTextBad.java"/>
24+
25+
<p>
26+
In the following (good) case, the user must press a button to reveal sensitive information.
27+
</p>
28+
29+
<sample src="AndroidSensitiveTextGood.java"/>
30+
</example>
31+
32+
<references>
33+
<li>
34+
OWASP Mobile Application Security: <a href="https://mas.owasp.org/MASTG/Android/0x05d-Testing-Data-Storage/#ui-components">Android Data Storage - UI Components</a>
35+
</li>
36+
</references>
37+
38+
</qhelp>

java/ql/src/Security/CWE/CWE-200/AndroidSensitiveTextField.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @name Exposure of sensitive information to UI text fields.
2+
* @name Exposure of sensitive information to UI text views.
33
* @id java/android/sensitive-text
44
* @kind path-problem
5-
* @description Sensitive information ... TODO
5+
* @description Sensitive information displayed in UI text views should be properly masked.
66
* @problem.severity warning
77
* @precision medium
88
* @security-severity 6.5
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
TextView pwView = findViewById(R.id.pw_text);
2+
pwView.setVisibility(View.INVISIBLE);
3+
pwView.setText("Your password is: " + password);
4+
5+
Button showButton = findViewById(R.id.show_pw_button);
6+
showButton.setOnClickListener(new View.OnClickListener() {
7+
public void onClick(View v) {
8+
pwView.setVisibility(View.VISIBLE);
9+
}
10+
});

0 commit comments

Comments
 (0)