2020-06-30 12:48:07 +02:00
include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
----
// === javax.servlet ===
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
public class JavaxServlet {
void aServiceMethodSettingCookie(HttpServletRequest request, HttpServletResponse response, String acctID) {
Cookie cookie = new Cookie("userAccountID", acctID); // Sensitive
response.addCookie(cookie); // Sensitive
}
}
----
----
// === javax.ws ===
import java.util.Date;
import javax.ws.rs.core.Cookie;
import javax.ws.rs.core.NewCookie;
class JavaxWs {
void jaxRsCookie(String comment, int maxAge, boolean secure, Date expiry, boolean httpOnly, String name,
String value, String path, String domain, int version) {
Cookie cookie= new Cookie("name", "value"); // Sensitive
new NewCookie(cookie); // Sensitive
new NewCookie(cookie, comment, maxAge, secure); // Sensitive
new NewCookie(cookie, comment, maxAge, expiry, secure, httpOnly); // Sensitive
new NewCookie(name, value); // Sensitive
new NewCookie(name, value, path, domain, version, comment, maxAge, secure); // Sensitive
new NewCookie(name, value, path, domain, version, comment, maxAge, expiry, secure, httpOnly); // Sensitive
new NewCookie(name, value, path, domain, comment, maxAge, secure); // Sensitive
new NewCookie(name, value, path, domain, comment, maxAge, secure, httpOnly); // Sensitive
}
}
----
----
// === java.net ===
import java.net.HttpCookie;
class JavaNet {
void httpCookie(HttpCookie hc) {
HttpCookie cookie = new HttpCookie("name", "value"); // Sensitive
cookie.setValue("value"); // Sensitive
}
}
----
----
// === apache.shiro ===
import org.apache.shiro.web.servlet.SimpleCookie;
class ApacheShiro {
void shiroCookie(SimpleCookie cookie) {
SimpleCookie sc = new SimpleCookie(cookie); // Sensitive
cookie.setValue("value"); // Sensitive
}
}
----
----
// === Play ===
import play.mvc.Http.Cookie;
import play.mvc.Http.CookieBuilder;
class Play {
void playCookie() {
CookieBuilder builder = Cookie.builder("name", "value"); // Sensitive
builder.withName("name")
.withValue("value") // Sensitive
.build();
}
}
----
2021-09-21 15:40:35 +02:00
== See
2022-07-08 13:58:56 +02:00
* https://www.owasp.org/www-project-top-ten/2017/A3_2017-Sensitive_Data_Exposure[OWASP Top 10 2017 Category A3] - Sensitive Data Exposure
2022-04-07 08:53:59 -05:00
* https://cwe.mitre.org/data/definitions/312[MITRE, CWE-312] - Cleartext Storage of Sensitive Information
* https://cwe.mitre.org/data/definitions/315[MITRE, CWE-315] - Cleartext Storage of Sensitive Information in a Cookie
2021-09-21 15:40:35 +02:00
* https://wiki.sei.cmu.edu/confluence/display/java/FIO52-J.+Do+not+store+unencrypted+sensitive+information+on+the+client+side[CERT, FIO52-J.] - Do not store unencrypted sensitive information on the client side
* Derived from FindSecBugs rule https://find-sec-bugs.github.io/bugs.htm#COOKIE_USAGE[COOKIE_USAGE]
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
2023-05-25 14:18:12 +02:00
=== Highlighting
* the ``++value++`` field, ie the second argument of the ``++new Cookie(...)++`` constructor
or
* the parameter of the ``++setValue++`` call on a Cookie object
2021-09-20 15:38:42 +02:00
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]