This section includes everything that is outside of the source code but is still critical to the security of the product that is being created. Because the issues covered by this kingdom are not directly related to source code, we separated it from the rest of the kingdoms.
serve
view of the static files
application which is not designed to be deployed in a production environment. According to Django documentation:static files
tools are mostly designed to help with getting static files successfully deployed into production. This usually means a separate, dedicated static file server, which is a lot of overhead to mess with when developing locally. Thus, the staticfiles app ships with a quick and dirty helper view that you can use to serve files locally in development.DEBUG
is True
.proxy_pass
directive, NGINX can forward all requests for /publicfolder
to the Tomcat server. The developer expects that only this folder is accessible to users. However, an attacker can send the next request http://targetserver/publicfolder/..;/manager/html
..;
to be a folder name so the path matches the rule and this request is forwarded to the Tomcat server. ..;
to indicate parent directory and will map the request to /publicfolder/../manager/html
, giving the attacker access to the manager app of Tomcat server.admin
application is deployed in a predictable URL:
from django.conf.urls import patterns
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
...
url(r'^admin/', include(admin.site.urls)),
...
<Realm className="org.apache.catalina.realm.JAASRealm"
appName="SRN"
userClassNames="com.srn.security.UserPrincipal"
roleClassNames="com.srn.security.RolePrincipal"/>
Realm
tag takes an optional attribute called debug
, which indicates the log level. The higher the number, the more verbose the log messages. If the debug level is set too high, Tomcat will write all usernames and passwords in plain text to the log file. The cutoff for debugging messages related to Tomcat's JAASRealm
is 3 (3 or greater is bad, 2 or less is okay), but this cutoff may vary for the other types of realms that Tomcat provides.http://host/page.jsp%00
or http://host/page.js%2570
. Even worse, if an application permits users to upload arbitrary files, attackers may use this mechanism to upload malicious code in the form of a JSP and request the uploaded page to cause the malicious code to execute on the server.
<security-constraint>
<web-resource-collection>
<web-resource-name>JSP Access for Everyone!</web-resource-name>
<description>Allow any user/role access to JSP</description>
<url-pattern>*.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
web.xml
file defines two admin
roles.
<security-constraint>
<web-resource-collection>
<web-resource-name>AdminPage</web-resource-name>
<description>Admin only pages</description>
<url-pattern>/auth/noaccess/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>Administrators only</description>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
...
<security-role>
<description>Administrator</description>
<role-name>admin</role-name>
</security-role>
<security-role>
<description>Non-Administrator</description>
<role-name>admin</role-name>
</security-role>
/servletA/*
is used in two different servlet mappings.
<servlet-mapping>
<servlet-name>ServletA</servlet-name>
<url-pattern>/servletA/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletB</servlet-name>
<url-pattern>/servletA/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-class>com.class.MyServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/myservlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/helloworld*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/servlet*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/mservlet*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>-1</session-timeout>
</session-config>
<session-timeout>
tag defines the default session timeout interval for all sessions in the web application. If the <session-timeout>
tag is missing, it is left to the container to set the default timeout.web.xml
is an error. Every Servlet should have a unique name (servlet-name
) and a corresponding mapping (servlet-mapping
).web.xml
shows several erroneous servlet definitions.
<!-- No <servlet-name> specified: -->
<servlet>
<servlet-class>com.class.MyServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Empty <servlet-name> node: -->
<servlet>
<servlet-name/>
<servlet-class>com.class.MyServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Duplicate <servlet-name> nodes: -->
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-name>Servlet</servlet-name>
<servlet-class>com.class.MyServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<login-config>
element is used to configure how users authenticate to an application. A missing authentication method means the application does not know how to apply authorization constraints since no one can log in. The authentication method is specified using the <auth-method>
tag, which is a child of <login-config>
.BASIC
, FORM
, DIGEST
, and CLIENT_CERT
.BASIC
denotes HTTP Basic authentication.FORM
denotes Form-based authentication.DIGEST
is like BASIC authentication; however, in DIGEST the password is encrypted.CLIENT_CERT
requires that clients have Public Key Certificates and use SSL/TLS.
<web-app>
<!-- servlet declarations -->
<servlet>...</servlet>
<!-- servlet mappings-->
<servlet-mapping>...</servlet-mapping>
<!-- security-constraints-->
<security-constraint>...</security-constraint>
<!-- login-config goes here -->
<!-- security-roles -->
<security-role>...</security-role>
</web-app>
web.xml
security constraints are typically used for role based access control, but the optional user-data-constraint
element specifies a transport guarantee that prevents content from being transmitted insecurely.<user-data-constraint>
tag, the <transport-guarantee>
tag defines how communication should be handled. There are three levels of transport guarantee:NONE
means that the application does not require any transport guarantees.INTEGRAL
means that the application requires that data sent between the client and server be sent in such a way that it cannot be changed in transit.CONFIDENTIAL
means that the application requires that data be transmitted in a fashion that prevents other entities from observing the contents of the transmission.INTEGRAL
or CONFIDENTIAL
means that SSL/TLS is required. If the <user-data-constraint>
and <transport-guarantee>
tags are omitted, the transport guarantee defaults to NONE
.
<security-constraint>
<web-resource-collection>
<web-resource-name>Storefront</web-resource-name>
<description>Allow Customers and Employees access to online store front</description>
<url-pattern>/store/shop/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description>Anyone</description>
<role-name>anyone</role-name>
</auth-constraint>
</security-constraint>