Introduction

CAST AIP provides support for a wide range of security rules that are established
by leading industry research and standards on security vulnerabilities. These security
rules are originated from established standards such as:

Consortium for IT Software Quality (CISQ) / OMG Automated Source
Code Security Measure Standard - MITRE has participated to the CISQ
initiative to specify an automated source code security measurement standard,
derived from the CWE Top 25 by focusing on automatable measurements. Please
also refer to MITRE own communication about their work with the CISQ:

The following tables explain the CAST AIP coverage for these security standards:

CAST AIP coverage for OWASP Top 10 - 2017

For more details on each vulnerability, you can check the OWASP website.

OWASP Vulnerability

Description

CAST AIP Coverage

A1-Injection

Injection flaws, such as SQL, OS, and LDAP injection occur when untrusted data is sent to an interpreter as part of a command or query. The attacker’s hostile data can trick the interpreter into executing unintended commands or accessing data without proper authorization.

Application functions related to authentication and session management are often not implemented correctly, allowing attackers to compromise passwords, keys, or session tokens, or to exploit other implementation flaws to assume other users’ identities.

Pre-built rule in CAST AIP

CAST supports the application/security architect by providing information about application structure, allowing the definition of custom rules using architecture checker, and the tracking and control of these rules in subsequent application development.

A3-Sensitive Data Exposure

Many web applications and APIs do not properly protect sensitive data, such as financial, healthcare, and PII. Attackers may steal or modify such weakly protected data to conduct credit card fraud, identity theft, or other crimes. Sensitive data may be compromised without extra protection, such as encryption at rest or in transit, and requires special precautions when exchanged with the browser.

Sensitive cryptography routines should be reviewed by a domain expert at the application-architecture level to ensure best practices are followed.

CAST supports with pre build rules and with application/security architect by providing information about application structure, allowing the definition of custom rules using architecture checker, and the tracking and control of these rules in subsequent application development.

CAST supports the application/security architect by providing information about application structure, allowing the definition of custom rules using architecture checker, and the tracking and control of these rules in subsequent application development.

A5-Broken Access Control

Restrictions on what authenticated users are allowed to do are often not properly enforced. Attackers can exploit these flaws to access unauthorized functionality and/or data, such as access other users' accounts, view sensitive files, modify other users' data, change access rights, etc.

CAST supports the application/security architect by providing information about application structure, allowing the definition of custom rules using architecture checker, and the tracking and control of these rules in subsequent application development.

A6-Security Misconfiguration

Good security requires having a secure configuration defined and deployed for the application, frameworks, application server, web server, database server, and platform. Secure settings should be defined, implemented, and maintained, as defaults are often insecure. Additionally, software should be kept up to date.

CAST supports with pre-built rules and the application/security architect by providing information about application structure, allowing the definition of custom rules developed with SDK or architecture checker,

Application security policies should be reviewed by a domain expert at the application-architecture level to ensure best practices are followed.

A7-Cross-Site Scripting (XSS)

XSS flaws occur whenever an application takes untrusted data and sends it to a web browser without proper validation or escaping. XSS allows attackers to execute scripts in the victim’s browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites.

Insecure deserialization often leads to remote code execution. Even if deserialization flaws do not result in remote code execution, they can be used to perform attacks, including replay attacks, injection attacks, and privilege escalation attacks.

Cast provides to create custom rules using SDK, CAST supports the application/security architect by providing information about application structure, allowing the definition of custom rules using architecture checker, and the tracking and control of these rules in subsequent application development.

A9-Using Components with Known Vulnerabilities

Components, such as libraries, frameworks, and other software modules, almost always run with full privileges. If a vulnerable component is exploited, such an attack can facilitate serious data loss or server takeover. Applications using components with known vulnerabilities may undermine application defences and enable a range of possible attacks and impacts.

A complete inventory of the third parties (libraries, frameworks and tools) used by a project should be in place. Versions should be kept up-to-date, and current versions should be monitored for security weaknesses announcements.

These vulnerabilities are not possible to find using static analysis. CAST has integrations with vendors in the SCA space who track known vulnerabilities, to display them alongside CAST AIP findings.

A10-Insufficient Logging and monitoring

Insufficient logging and monitoring, coupled with missing or ineffective integration with incident response, allows attackers to further attack systems, maintain persistence, pivot to more systems, and tamper, extract, or destroy data. Most breach studies show time to detect a breach is over 200 days, typically detected by external parties rather than internal processes or monitoring.

These vulnerabilities are not possible to find using static analysis. CAST Consultant during the assessment would provide the feedback and will display them alongside CAST AIP findings.

CAST AIP coverage for OWASP Top 10 - 2013

For more details on each vulnerability, you can check the OWASP website.

OWASP Vulnerability

Description

CAST AIP Coverage

A1-Injection

Injection flaws, such as SQL, OS, and LDAP injection occur when untrusted
data is sent to an interpreter as part of a command or query. The attacker’s
hostile data can trick the interpreter into executing unintended commands
or accessing data without proper authorization.

Application functions related to authentication and session management
are often not implemented correctly, allowing attackers to compromise passwords,
keys, or session tokens, or to exploit other implementation flaws to assume
other users’ identities.

This is planned for a future release

A3-Cross-Site Scripting (XSS)

XSS flaws occur whenever an application takes untrusted data and sends
it to a web browser without proper validation or escaping. XSS allows attackers
to execute scripts in the victim’s browser which can hijack user sessions,
deface web sites, or redirect the user to malicious sites.

A direct object reference occurs when a developer exposes a reference
to an internal implementation object, such as a file, directory, or database
key. Without an access control check or other protection, attackers can
manipulate these references to access unauthorized data.

As described in the OWASP document these vulnerabilities are impossible
to check using source code analysis

A5-Security Misconfiguration

Good security requires having a secure configuration defined and deployed
for the application, frameworks, application server, web server, database
server, and platform. Secure settings should be defined, implemented, and
maintained, as defaults are often insecure. Additionally, software should
be kept up to date.

Application security policies should be reviewed by a domain expert at the application-architecture level to ensure best practices are followed.

CAST supports the application/security architect by providing information about application structure, allowing the definition of custom rules using architecture checker, and the tracking and control of these rules in subsequent application development.

A6-Sensitive Data Exposure

Many web applications do not properly protect sensitive data, such as
credit cards, tax IDs, and authentication credentials. Attackers may steal
or modify such weakly protected data to conduct credit card fraud, identity
theft, or other crimes. Sensitive data deserves extra protection such as
encryption at rest or in transit, as well as special precautions when exchanged
with the browser.

Sensitive cryptography routines should be reviewed by a domain expert at the application-architecture level to ensure best practices are followed.

CAST supports the application/security architect by providing information about application structure, allowing the definition of custom rules using architecture checker, and the tracking and control of these rules in subsequent application development.

A7-Missing Function Level Access Control

Most web applications verify function level access rights before making
that functionality visible in the UI. However, applications need to perform
the same access control checks on the server when each function is accessed.
If requests are not verified, attackers will be able to forge requests in
order to access functionality without proper authorization.

AIP is currently able to check that access control systems are in place for some presentation frameworks, such as Struts.

A8-Cross-Site Request Forgery (CSRF)

A CSRF attack forces a logged-on victim’s browser to send a forged HTTP
request, including the victim’s session cookie and any other automatically
included authentication information, to a vulnerable web application. This
allows the attacker to force the victim’s browser to generate requests the
vulnerable application thinks are legitimate requests from the victim.

Components, such as libraries, frameworks, and other software modules,
almost always run with full privileges. If a vulnerable component is exploited,
such an attack can facilitate serious data loss or server takeover. Applications
using components with known vulnerabilities may undermine application defences
and enable a range of possible attacks and impacts.

A complete inventory of the third parties (libraries, frameworks and tools) used by a project should be in place. Versions should be kept up-to-date, and current versions should be monitored for security weaknesses announcements.

These vulnerabilities are not possible to find using static analysis. CAST has integrations with vendors in the SCA space who track known vulnerabilities, to display them alongside CAST AIP findings.

A10-Unvalidated Redirects and Forwards

Web applications frequently redirect and forward users to other pages
and websites, and use untrusted data to determine the destination pages.
Without proper validation, attackers can redirect victims to phishing or
malware sites, or use forwards to access

As described in the OWASP document these vulnerabilities are impossible
to check using source code analysis

When the set of acceptable objects, such as filenames or URLs, is
limited or known, create a mapping from a set of fixed input values
(such as numericIDs) to the actual filenames or URLs, and reject all
other inputs.

This is handled by checking every internet library for vulnerability and maintaining a whitelist. Normally we can check the HTML code and parse the URL to verify the domain.

Extend the existing rule 2660 - Avoid XPath injection vulnerabilities

[18]

CWE-676

Use of Potentially Dangerous Function

Checking for programming best practices

Pre-built rule in AIP –

2279 - Avoid using snprintf() function

2280 - Avoid using realpath() function

2325 - Avoid using the scanf() function

[20]

CWE-131

Incorrect Calculation of Buffer Size

Perform input validation on any numeric input by ensuring that it
is within the expected range. Enforce that the input meets both the
minimum and maximum requirements for the expected range.

This is handled through a combination of existing quality rules listed below:

2327 - Never use sprintf() function or vsprintf() function

Never perform C cast between incompatible class pointers

2413 - Avoid using static_cast on class/struct pointers

[23]

CWE-134

Uncontrolled Format String

Checking for programming best practices

Checking for programming best practices

Pre-built inCAST AIP rule. Extend the following existing rules –

8098 - Uncontrolled format string

[24]

CWE-190

Integer Overflow or Wraparound

Perform check on any numeric input by ensuring that it is within the
expected range. Enforce that the input meets both the minimum and maximum
requirements for the expected range.

These rules require using DF with Arithmetics. This will be handled by extending the existing rule, 2282 - Avoid using getopt() function

Porous Defences

The weaknesses in this category are related to defensive techniques that are
often misused, abused, or just plain ignored.

Rank

CWE ID

Name

Recommendation/Mitigation/Comments

Coverage with CAST AIP

[5]

CWE-306

Missing Authentication for Critical Function

avoid implementing custom authentication routines and consider using
authentication capabilities as provided by the surrounding framework,
operating system, or environment.

This requirement is achieved using DF and User input security and extending existing rules –

2284 - Avoid cross-site scripting vulnerabilities,

2662 - Avoid LDAP injection vulnerabilities

[6]

CWE-862

Missing Authorization

Users should not be able to access any unauthorized functionality
or information by simply requesting direct access to that page.

This requirement will be achieved using DF and User input security
and extending existing rules –

2284 - Avoid cross-site scripting vulnerabilities

2662 - Avoid LDAP injection vulnerabilities

[8]

CWE-311

Missing Encryption of Sensitive Data

Periodically ensure that you aren't using obsolete cryptography.
Avoid using old encryption techniques using MD4, MD5, SHA1, DES, and
other algorithms that were once regarded as strong.

Checking of encryption can be handled using custom rules that check for the use of known encryption functions and/or libraries -

Checking for privileges being appropriately implemented based on
the scenario/use case. Perform extensive input validation and canonicalization
to minimize the chances of introducing a separate vulnerability.

This is more linked to dynamic analysis and not directly handled by CAST AIP today. We can extend existing rules to cover part of this requirement –

This will be addressed by creating a blacklist of functions considered risky or broken (Handle via maintaining blacklist of well known and crypto algorithms) and applying custom architectural rules to check for the use of appropriate functions.

[21]

CWE-307

Improper Restriction of Excessive Authentication Attempts

Check login implementation

This will be handled by extending the following existing rules –

521 - Avoid direct access to database Procedures/Functions

750 - User Interface elements must not use directly the database|

[25]

CWE-759

Use of a One-Way Hash without a Salt

Checking for programming best practices. Best practice, always use
initialises that contain salt for Hash. Instead of calling Hashlib with
just one parameter use additional parameters for salt.

This will be addressed by blacklisting methods that does not contain
the good initialization parameters. Extend the following existing rules
–

The software does not check the return value from a method or function,
which can prevent it from detecting unexpected states and conditions.

Checking the return value of the function will typically be sufficient,
however beware of race conditions (CWE-362)
in a concurrent environment.

Supported from CAST AIP 8.0 onwards

CWE-681

When converting from one data type to another, such as long to integer,
data can be omitted or translated in a way that produces unexpected values.

Avoid making conversion between numeric types. Always check for the allowed
ranges.

Supported from CAST AIP 8.0 onwards

CAST AIP coverage for CISQ Security

For more details on each vulnerability, you can check the OWASP website.

CISQ Security Identifier

Description

CAST AIP Coverage

ASCSM-CWE-22

Improper path traversal - Remove instances where a user input is ultimately used in a file path creation statement, without any sanitization (based on a list of vetted sanitization functions, methods, procedures, stored procedures, sub-routines, etc.) of the user input value between the user input and the statement.

OS command injection - Remove instances where a user input is ultimately used to execute an OS command, without any sanitization (based on a list of vetted sanitization functions, methods, procedures, stored procedures, sub-routines, etc.) of the user input value between the user input and the statement.

Cross-site scripting - Remove instances where a user input is ultimately displayed to the user, without any sanitization (based on a list of vetted sanitization functions, methods, procedures, stored procedures, sub-routines, etc.) of the user input value between the user input and the statement.

SQL injection - Remove instances where a user input is ultimately used in a SQL statement, without any sanitization (based on a list of vetted sanitization functions, methods, procedures, stored procedures, sub-routines, etc.) of the user input value between the user input and the statement.

Unsanitized user input used to access a named resource - Remove instances where a user input is ultimately used to access a resource by name, without any sanitization (based on a list of vetted sanitization functions, methods, procedures, stored procedures, sub-routines, etc.) of the user input value between the user input and the statement.

Pre-built rules in CAST AIP

ASCSM-CWE-120

Buffer overflow - Remove instances where the content of the first buffer is moved into the content of the second buffer while their allocated sizes are incompatible

Pre-built rules in CAST AIP

ASCSM-CWE-129

Unchecked array index range - Remove instances where a user input is ultimately used in a ‘Read’ or ‘Write’ access to an array, without any range check between the user input and the array access.

CAST supports the application/security architect by providing information about application structure, allowing the definition of custom rules using architecture checker, and the tracking and control of these rules in subsequent application development.

ASCSM-CWE-134

Improper format string neutralization - Remove instances where a user input is ultimately used in a formatting statement, without any sanitization (based on a list of vetted sanitization functions, methods, procedures, stored procedures, sub-routines, etc.) of the user input value between the user input and the statement.

Unsanitized user input in file upload statement - Remove instances where a user input is ultimately used in a file upload statement, without any sanitization (based on a list of vetted sanitization functions, methods, procedures, stored procedures, sub-routines, etc.) of the user input value between the user input and the statement.

Pre-built rules in CAST AIP

ASCSM-CWE-456

Uninitialized data element - Remove instances where a variable, field, member, etc. is declared, then is evaluated without ever being initialized prior to the evaluation.

Pre-built rules in CAST AIP

ASCSM-CWE-606

Unchecked input in loop condition - Remove instances where a user input is ultimately used in the loop condition statement, without any range check between the user input and the loop statement.

Access to released or expired resources - Remove instances where the platform resource (messaging, lock, file, stream, etc.) is deallocated using its unique resource handler which is used later within the application to try and access the resource.

Pre-built rules in CAST AIP

ASCSM-CWE-681

Incompatible numeric type conversion - Remove instances where a variable, field, member, etc. is declared with a numeric type, and then is updated with a value from a second numeric type that is incompatible with the first numeric type

Pre-built rules in CAST AIP

ASCSM-CWE-772

Unreleased resource - Remove instances where a variable, field, member, etc. is declared with a numeric type, and then is updated with a value from a second numeric type that is incompatible with the first numeric type

Pre-built rules in CAST AIP

ASCSM-CWE-789

Unchecked range of user input to a buffer - Remove instances where a user input is ultimately used in a ‘Read’ or ‘Write’ access to a buffer, without any range check between the user input and the buffer access.

Pre-built rules in CAST AIP

ASCSM-CWE-798

Hard‐coded credentials for remote resources - Remove instances where a variable, field, member, etc., is initialized with a hard-coded literal value, and ultimately used to access a remote resource.

CAST AIP coverage for PCI DSS

6.2 Establish a process to identify and assign a risk
ranking to newly discovered security vulnerabilities.

CAST AIP can be seamlessly integrated into the existing development process
either at the build phase or before testing phase.

CAST AIP also
automatically assigns ranks to the vulnerabilities through a combination
of vulnerability severity, determined by industry standards, and the risk
the specific vulnerability presents to the application as a whole (though
propagation risk analysis and transaction risk analysis)

In addition
to identifying the vulnerability, CAST AIP also provides detailed guidance
on how to fix the vulnerability with sample code.

6.3 Develop software applications (internal and external,
and including web-based administrative access to applications) in accordance
with PCI DSS (for example, secure authentication and logging), and based
on industry best practices, and incorporate information security throughout
the software development life cycle.6.3.2 Review of
custom code prior to release to production or customers in order to identify
any potential coding vulnerability.

CAST AIP out of the box includes more than 300 security best practices
that cover nearly 30 programming languages. Also, CAST AIP can be integrated
into the SDLC to automate the process of code analysis to identify these
vulnerabilities.

6.4 Follow change control processes and procedures for
all changes to system components.

CAST Discovery Portal, creates an automatic blue print of the entire
system dependencies and also specifically identifies the code added, modified
and deleted. This information can expedite the process of following change
control procedures.

CAST AIP addresses most of these requirements.Please see CAST AIP
coverage of OWASP and CWE Top 25.

6.6 For public-facing web applications, address new
threats and vulnerabilities on an ongoing basis and ensure these applications
are protected against known attacks by reviewing public-facing web applications
via manual or automated application vulnerability security assessment tools
or methods, at least annually and after any changes

Detailed Notes on Specific OWASP Rules

OWASP 2013 - A1 – Injection Flaws

"Injection flaws, particularly SQL injection, are common in web applications.
There are many types of injections: SQL, LDAP, XPath, XSLT, HTML, XML, OS command
injection and many more.Injection occurs when user-supplied data is sent
to an interpreter as part of a command or query. Attackers trick the interpreter
into executing unintended commands via supplying specially crafted data."

CAST AI Platform integrates a User Input Security Analyzer based on dataflow
technology. The Dataflow User Input Security Analyzer is a technology embedded
in the code analyzer that uses tainted variable analysis and tracks input data thru
out the source code to find a path where the input data is sent to a target server
without prior sanitization / encoding.

The User Input Security Analyzer can be customized to specific need interactively
to add specific sanitization, input or target methods for a given type of flaw.
The Dataflow User Input Security Analyzer offer manager and developers the view
of the precise path(s) where the vulnerability exist in a call path view directly
in the CAST dashboards.

In addition to the dataflow searched quality rules, CAST AI Platform provides
out of the box the following framework based rules also grouped into the technical
criteria metric called "Secure Coding - Input Validation":

For applications following the OWASP recommendation to implement object relational
mapping (ORM) libraries such as Hibernate, CAST provides a specific rule that checks
that only Hibernate is used to access the database:

Hibernate: Use only Hibernate API to access to the database

CAST provides also 13 rules to check that Hibernate architecture & performance
best practices are in place.

OWASP 2013 - A3 – Cross Site Scripting (XSS)

"Cross-site scripting, better known as XSS, is in fact a subset of HTML injection.
XSS is the most prevalent and pernicious web application security issue. XSS flaws
occur whenever an application takes data that originated from a user and sends it
to a web browser without first validating or encoding that content."

Being a special form of injection, a part of the solution to get rid of the XSS
threat comes from checking the protection in place for A2 Injection Flaws (see A2).
Indeed, beside A2 protection (validation of all incoming data), the OWASP Top Ten
document recommends the "appropriate encoding of all output data".

CAST supports checking that using the same technology as for Injection Flaws:
dataflow and tainted variable analysis to track input data thru out the source code
in order find a path where the input data is sent back to the user without prior
sanitization / encoding. The User Input Security Analyzer offers directly supports
Cross-Site Scripting flaws that can be found in the technical criteria metric called
"Secure Coding - Input Validation". As for A1-Injection flaws,
the user can customize interactively the analysis to meet specific needs: adding
specific sanitization, input or target methods for a given type of flaw is done
directly thru the GUI. XSS results are displayed in the dashboard which offers the
view of precise path(s) where the vulnerability exist in a call path view directly
in CAST AD Dashboard.

OWASP 2013 - A8 – Cross-Site Request Forgery (CSRF)

"A CSRF attack forces a logged-on victim’s browser to send a forged HTTP
request, including the victim’s session cookie and any other automatically included
authentication information, to a vulnerable web application. This allows the attacker
to force the victim’s browser to generate requests the vulnerable application thinks
are legitimate requests from the victim."

Most CSRF defences can be bypassed using attacker-controlled script, so the a
required step to protect against A8 is to implement a proper Cross Site Scripting
protection. See the description for A3 above.

OWASP 2007 - A6 – Information Leakage and Improper
Error Handling

Rule of a previous version of the OWASP Top 10 with no equivalent in recent versions. Kept here for reference.

"Applications can unintentionally leak information about their configuration,
internal workings, or violate privacy through a variety of application problems.
Applications can also leak internal state via how long they take to process certain
operations or via different responses to differing inputs, such as displaying the
same error text with different error numbers. Web applications will often leak information
about their internal state through detailed or debug error messages. Often, this
information can be leveraged to launch or even automate more powerful attacks."
CAST supports the protection against "A6 – Information Leakage and Improper Error
Handling" thru the use of the following rules integrated in the technical criteria
metric called "Programming Practices - Error and Exception Handling":