-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathConditionalBypass.qhelp
More file actions
47 lines (35 loc) · 1.88 KB
/
ConditionalBypass.qhelp
File metadata and controls
47 lines (35 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>Many Java constructs enable code statements to be executed conditionally, for example <code>if</code>
statements and <code>for</code> statements. If these statements contain important authentication or
login code, and the decision about whether to execute this code is based on user-controlled data, it
may be possible for an attacker to bypass security systems by preventing this code from executing.</p>
</overview>
<recommendation>
<p>Never decide whether to authenticate a user based on data that may be
controlled by that user. If necessary, ensure that the data is
validated extensively when it is input before any authentication checks are performed.</p>
<p>
It is still possible to have a system that "remembers" users, thus not requiring the user to login
on every interaction. For example, personalization settings can be applied without authentication
because this is not sensitive information. However, users should be allowed to take sensitive
actions only when they have been fully authenticated.
</p>
</recommendation>
<example>
<p>This example shows two ways of deciding whether to authenticate a user. The first way shows a
decision that is based on the value of a cookie. Cookies can be easily controlled by the user, and
so this allows a user to become authenticated without providing valid credentials. The second, more
secure way shows a decision that is based on looking up the user in a security database.</p>
<sample src="ConditionalBypass.java" />
</example>
<references>
<li>SEI CERT Oracle Coding Standard for Java:
<a href="https://wiki.sei.cmu.edu/confluence/display/java/SEC02-J.+Do+not+base+security+checks+on+untrusted+sources">SEC02-J. Do not base security checks on untrusted sources</a>.</li>
<!-- LocalWords: CWE login personalization Untrusted untrusted
-->
</references>
</qhelp>