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.
open_basedir
configuration option attempts to prevent PHP programs from operating on files outside of the directory trees specified in php.ini. If no directories are specified using the open_basedir
option, then programs running under PHP are given full access to arbitrary files on the local file system, which can allow attackers to read, write or create files that they should not be able to access.open_basedir
can make it easier for attackers to exploit other vulnerabilities.open_basedir
option is an overall boon to security, the implementation suffers from a race condition that can permit attackers to bypass its restrictions in some circumstances [2]. A time-of-check, time-of-use (TOCTOU) race condition exists between the time PHP performs the access permission check and when the file is opened. As with file system race conditions in other languages, this race condition can allow attackers to replace a symlink to a file that passes an access control check with another for which the test would otherwise fail, thereby gaining access to the protected file.safe_mode
is enabled, the safe_mode_exec_dir
option restricts PHP to executing commands from only the specified directories. Although the absence of a safe_mode_exec_dir
entry does not represent a security vulnerability itself, this added leniency can be exploited by attackers in conjunction with other vulnerabilities to make exploits more dangerous.open_basedir
configuration specifies the working directory which can be changed.open_basedir
configuration option attempts to prevent PHP programs from operating on files outside of the directory trees specified in php.ini. If the working directory is specified with .
, this can potentially be changed by an attacker by using chdir()
.open_basedir
option is an overall boon to security, the implementation suffers from a race condition that can permit attackers to bypass its restrictions in some circumstances [2]. A time-of-check, time-of-use (TOCTOU) race condition exists between the time PHP performs the access permission check and when the file is opened. As with file system race conditions in other languages, this race condition can allow attackers to replace a symlink to a file that passes an access control check with another for which the test would otherwise fail, thereby gaining access to the protected file.register_globals
option causes PHP to register all EGPCS (Environment, GET, POST, Cookie, and Server) variables globally, where they can be accessed in any scope in any PHP program. This option encourages programmers to write programs that are more-or-less unaware of the origin of values they rely on, which can lead to unexpected behavior in benign environments and leaves the door open to attackers in malicious environments. In recognition the dangerous security implications of register_globals
, the option was disabled by default in PHP 4.2.0 and was deprecated and removed in PHP 6.$username
originates from the server-controlled session, but an attacker may supply a malicious value for $username
as a request parameter instead. With register_globals
enabled, this code will include a malicious value submitted by an attacker in the dynamic HTML content it generates.
<?php
if (isset($username)) {
echo "Hello <b>$username</b>";
} else {
echo "Hello <b>Guest</b><br />";
echo "Would you like to login?";
}
?>
safe_mode
option is one of the most important security features in PHP. When safe_mode
is disabled, PHP operates on files with the permissions of the user that invoked it, which is often a privileged user. Although configuring PHP with safe_mode
disabled does not introduce a security vulnerability itself, this added leniency can be exploited by attackers in conjunction with other vulnerabilities to make exploits more dangerous.session.use_trans_sid
causes PHP to pass the session ID on the URL, which makes it much easier for attackers to hijack active sessions or trick users into using an existing session already under the attackers' control.open_basedir
configuration option contains a design flaw that leaves it vulnerable to file access race conditions, which can allow an attacker to circumvent access control checks on the file system.open_basedir
configuration option attempts to prevent PHP programs from operating on files outside of the directory trees specified in php.ini. Although the open_basedir
option is an overall boon to security, the implementation suffers from a race condition that can permit attackers to bypass its restrictions in some circumstances [2]. A time-of-check, time-of-use (TOCTOU) race condition exists between the time PHP performs the access permission check and when the file is opened. As with file system race conditions in other languages, this vulnerability can allow attackers to replace a symlink to a file that passes the access control check with another for which the test would otherwise fail, thereby gaining access to the protected file.Reference
element. Usually, the Transform
operation aims at selecting just a subset of the referenced data. However, an attacker could use some types of transforms to cause a denial of service and in some environments even arbitrary code execution. Examples of such insecure types are XSLT (Extensible Stylesheet Language Transformations) and XPath transforms.form-bean
entries with the same name exist. Duplicate form-bean
names often indicate left over debug code or a typographical error.form-bean
names serve no purpose since only the last entry will be registered when the same name is used in multiple <form-bean>
tags.form-bean
entries with the same name.
<form-beans>
<form-bean name="loginForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="name" type="java.lang.String" />
<form-property name="password" type="java.lang.String" />
</form-bean>
<form-bean name="loginForm" type="org.apache.struts.validator.DynaActionForm">
<form-property name="favoriteColor" type="java.lang.String" />
</form-bean>
</form-beans>
path
attribute to locate the resource necessary to handle a request. Since the path is a module-relative location, it is an error if it does not begin with a "/" character.Example 2: The following configuration uses a path that does not start with a "/" character.
<global-exceptions>
<exception key="global.error.invalidLogin" path="" scope="request" type="InvalidLoginException" />
</global-exceptions>
<global-forwards>
<forward name="login" path="Login.jsp" />
</global-forwards>
input
attribute for named Struts actions that can return validation errors..input
attribute whenever a named action returns validation errors[2]. The input
attribute specifies the page used to display error messages when validation errors occur.input
attribute.
<action-mappings>
<action path="/Login"
type="com.LoginAction"
name="LoginForm"
scope="request"
validate="true" />
</action-mappings>
<exception>
tag that does not contain a type
attribute will not be used.<exception>
tag requires that an exception type be defined. A missing or empty type
attribute is indicative of either a superfluous exception handler or an accidental omission. If a developer intended to handle an exception, but forgot to define the exception type, then the application might leak sensitive information about the system.<exception>
tag.
<global-exceptions>
<exception
key="error.key"
handler="com.mybank.ExceptionHandler"/>
</global-exceptions>
action
that points to a nonexistent form-bean
will not be mapped correctly.form-bean
entries to map HTML forms to actions. If the name
attribute in an <action>
tag does not correspond with the name of a form-bean
, the action cannot be mapped and indicates either a superfluous definition or a typographical error.bean2
.
<form-beans>
<form-bean name="bean1" type="coreservlets.UserFormBean" />
</form-beans>
<action-mappings>
<action path="/actions/register1" type="coreservlets.RegisterAction1" name="bean1" scope="request" />
<action path="/actions/register2" type="coreservlets.RegisterAction2" name="bean2" scope="request" />
</action-mappings>
form-bean
without a name
attribute will not be used.form-bean
name to map HTML forms to actions. If a form-bean
does not have a name, it cannot be mapped to an action and indicates either a superfluous definition or an accidentally omitted bean.form-bean
has an empty name
attribute.
<form-beans>
<form-bean name="" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="name" type="java.lang.String" />
<form-property name="password" type="java.lang.String" />
</form-bean>
</form-beans>
form-bean
without a type
attribute will not be mapped correctly.form-bean
entries to map HTML forms to actions. If a form-bean
does not have a type, it cannot be mapped to an action.form-bean
has an empty type
attribute.
<form-beans>
<form-bean name="loginForm" type="">
<form-property name="name" type="java.lang.String" />
<form-property name="password" type="java.lang.String" />
</form-bean>
</form-beans>
form-property
without a type
type attribute.<form-property>
tags to include a type
attribute. Struts will throw an exception when processing a form that defines a form-property
with no type.name
property.
<form-bean name="loginForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="name" />
<form-property name="password" type="java.lang.String" />
</form-bean>
<forward>
tag with a missing name
attribute often indicates leftover debug code or a typographical error.<forward>
tag must have name
and path
attributes. Without a name, the forward
will never be used.<forward>
tag has an empty name
attribute.
<forward name="" path="/results.jsp"/>
<forward>
tag with a missing path
attribute often indicates leftover debug code or a typographical error.<forward>
tag must have name
and path
attributes. It is an error to omit a path or to specify a blank path. Furthermore, all paths must start with the "/" character.<forward>
tag has a missing path
attribute.
<forward name="success" />
display_errors
option is enabled, errors are displayed to the Web, which can illustrate potential weaknesses to an attacker. For example, a database error message can reveal that the application is vulnerable to a SQL injection attack. Other error messages can reveal more oblique clues about the system.