Secure Coding SwA Pocket Guide - Build Security In - US-CERT
Secure Coding SwA Pocket Guide - Build Security In - US-CERT
Secure Coding SwA Pocket Guide - Build Security In - US-CERT
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
To find out other ways to protect the state data that the software needs to retain, see the mitigations for CWE 642 “ExternalControl of Critical State Data” in the Key Practices for Mitigating the Most Egregious Exploitable Software Weaknesses pocketguide.Resources» “Temporary files security in-depth.” Lewis, Richard. Application <strong>Security</strong>. 12 October 2006. 28 July2010 .Do Not Allow Unauthorized Privilege EscalationThe programmer should not write logic that enables users or processes to perform privilege escalations. Attackers can observe aprocess that attempts to reference another process that has higher privileges than its own. The attackers will interpret suchactions on the first process’ part as indicating laxness in privilege enforcement and authentication validation by the softwaresystem. Processes with higher privileges than the attacker should not be visible to the attacker. If attackers can see the higherprivileged process, they can exploit it to escalate their own privileges.Leverage <strong>Security</strong> through Obscurity Only as an AdditionalDeterrence Measure<strong>Security</strong> through obscurity measures, such as code obfuscation, use of hidden files, etc., at best provide a weak deterrenceagainst reconnaissance attacks and reverse engineering. While such measures can be an inconvenience for unsophisticated andcasual attackers, they should only be used in addition to a robust set of true security measures.Use Strongly Typed Parameterized QueriesParameterized queries use placeholders to separate the query and data. The query structure is defined with placeholders, theSQL statement is sent to the database and prepared, and then the prepared statement is combined with the parameter values.This prevents the query from being altered, because the parameter values are combined with the compiled statement, not a SQLstring, and therefore, helps protect against SQL injection attacks [CWE 89].<strong>In</strong>corporate <strong>In</strong>terprocess AuthenticationThe primary purpose of interprocess authentication is to link the identity and privileges of a human user with those of theapplication processes that operate on his/her behalf. This allows the software system to make decisions based on the user’s(whether human or software entity) security-relevant attributes, such as whether to grant the entity access to certain data orresources. This also allows the system to link a software process’ actions to its user’s authenticated identity for purposes ofaccountability. Authentication using Kerberos tickets, <strong>Security</strong> Assertion Markup Language assertions, SSL/TLS with X.509certificates or one-time encrypted cookies, secure remote procedure call (RPC) protocols (described below), etc., enables thebinding of a human identity with a software process that will act on that human’s behalf.However, new computing models require the ability of autonomous processes to dynamically invoke other autonomous softwareprocesses or agents. <strong>In</strong> turn these agents can dynamically invoke yet more autonomous processes/agents, all of which may bewidely distributed throughout the software-intensive system or even belong to other software systems—resulting in a system ofsystems. Under such conditions, it becomes extremely difficult, if not impossible, to extend the association of a human with eachprocess or agent subsequently invoked by the first process/agent with which the user is associated. Authentication andaccountability becomes a matter of keeping track of all the downstream processes/agents that are invoked as part of the need torespond to the original user request or action that originally associated that user with the first process/agent in the chain.Grid computing initiatives, such as the Globus Grid <strong>Security</strong> <strong>In</strong>frastructure, are defining solutions such as “run-anywhere” singlesign-onauthentication of grid agents using SSL/TLS and X.509 certificates [Globus]. Moreover, the emergence of agent-basedSoftware Assurance <strong>Pocket</strong> <strong>Guide</strong> Series:Development Volume VI – Version 2.0, , May 18, 2012<strong>Secure</strong> <strong>Coding</strong>17