Sunday, December 23, 2012

Security: Network security


An example listing of components in an Applications environment: 

application firewall
web server
application server
middleware servers
databases
web caches
stateful firewalls
routers
switches
Domain Servers
OTP servers
RSA secureID servers
PKI /TACACS/Radius servers-HIDS/HIPS
NIDS/NIPS
Syslog and log aggregation servers
Anti-Virus servers/appliances
Load Balancers/reverse proxies


Top network level threats include:

  • Information gathering
  • Sniffing
  • Spoofing
  • Session hijacking
  • Denial of service
Top host level threats include:
  • Viruses, Trojan horses, and worms
  • Footprinting ( ping sweep, NETBIOS enumeration).
  • Profiling
  • Password cracking
  • Denial of service
  • Arbitrary code execution
  • Unauthorized access

refer for notes http://www.ixiacom.com/pdfs/library/white_papers/SecurityOverviewWhitePaper.pdf



Sunday, December 9, 2012

Security: Security Architecture and design

   Trusted computing base (TCB) is defined as the total combination of protection mechanisms within a computer system. The TCB includes hardware, software, and firmware. These components will enforce the security policy and not violate it.

    If the TCB is enabled, then the system has a trusted path, a trusted shell, and system integrity-checking capabilities. The TCB provides protection resources to ensure the trusted path (channel between the user, or program, and the kernel) cannot be compromised in any way. A trusted shell prevents "bust out of it," and "bust into it" phenomenon.

    The four basic functions of the TCB are process activation, execution domain switching, memory protection, and I/O operations.
Execution domain switching refers to when the CPU has to go from executing instructions in user mode to privileged mode and back.

The reference monitor
is an abstract machine that mediates all access subjects have to objects, both to ensure that the subjects have the necessary access rights and to protect the objects from unauthorized access and destructive modification.

The security kernel is made up of hardware, software, and firmware components that fall within the TCB, and it implements and enforces the reference monitor concept.

The reference monitor is a concept in which an abstract machine mediates all access to objects by subjects. The security kernel is the hardware, firmware, and software of a TCB that implements this concept. The TCB is the totality of protection mechanisms within a computer system that work together to enforce a security policy. The TCB contains the security kernel and all other security protection mechanisms.

Security model
Models such as the Bell-LaPadula model, enforce rules to provide confidentiality protection. Other models, such as the Biba model, enforce rules to provide integrity protection. Formal security models, such as Bell-LaPadula and
Biba, are used to provide high assurance in security. Informal models, such as Clark-Wilson, are used more as a framework to describe how security policies should be expressed and executed.

The Bell-LaPadula model 

is a state machine model that enforces the confidentiality aspects of access control. A matrix and security levels are used to determine if subjects can
access different objects. The subject's clearance is compared to the object's classification and then specific rules are applied to control how subject-to-object interactions can take place. It is a subject-to-object model.

  • The simple security rule states that a subject at a given security level cannot read data that reside at a higher security level.
  • The *-property rule (star property rule) states that a subject in a given security level cannot write information to a lower security level. 
  • The simple security rule is referred to as the "no read up" rule, and the *-property rule is referred to as the "no write down" rule. 
  • The third rule, the strong star property rule, states that a subject that has read and write capabilities can only perform those functions at the same security level, nothing higher and nothing lower.
Basic Security Theorem used in computer science, which states that if a system initializes in a secure state and all allowed state transitions are secure, then every
subsequent state will be secure no matter what inputs occur.

The tranquility principle, which is also used in this model, means that subjects and objects cannot change their security levels once they have been instantiated

Mandatory access control (MAC) systems are based on the Bell-LaPadula model, because it allows for multilevel security to be integrated into the code.

Bell-LaPadula has a rule called Discretionary Security Property (ds-property). It specifies that specific permissions allow a subject to pass on permissions at its own discretion. These permissions are stored in an access matrix. Basically implying that mandatory and discretionary access control mechanisms can be implemented in one operating system.

Biba Model

It addresses the integrity of data within applications. The Biba model is not concerned with security levels and confidentiality, so it does not base access decisions upon this type of lattice. The Biba model uses a lattice of integrity
levels.
Biba model prevents data from any integrity level from flowing to a higher
integrity level. Biba has three main rules:
  • *-integrity axiom A subject cannot write data to an object at a higher integrity level (referred to as "no write up").
  • Simple integrity axiom A subject cannot read data from a lower integrity level (referred to as "no read down").
  • Invocation property A subject cannot request service (invoke) to subjects of higher integrity.

Bell-LaPadula vs. Biba

The Bell-LaPadula and Biba models are informational flow models but the Bell-LaPadula model is used to provide confidentiality while the Biba model is used to provide integrity.
Bell-LaPadula uses security levels, and Biba uses integrity levels.
Their rules sound very similar: simple and * rules—one writing one way and one reading another way. A tip for how to remember them is that if the word "simple" is used, the rule is talking about reading. If the rule uses * or "star," it is talking about writing.

The Clark-Wilson Model

The Clark-Wilson model was developed after Biba and takes some different approaches to protecting the integrity of information. This model uses the following elements:
Users Active agents
Transformation procedures (TPs) Programmed abstract operations, such as read, write, and modify
Constrained data items (CDIs) Can be manipulated only by TPs
Unconstrained data items (UDIs) Can be manipulated by users via primitive read and write operations
Integrity verification procedures (IVPs) Check the consistency of CDIs with external reality
When an application uses the Clark-Wilson model, it separates data into one subset that needs to be highly protected, which is referred to as a constrained data item (CDI), and another subset that does not require a high level of protection, which is called an unconstrained data item (UDI). Users cannot modify critical data (CDI) directly. Instead, the subject (user) must be authenticated to a piece of software, and the software procedures (TPs) will carry out the operations on behalf of the user.

Goals of Integrity Models
  • The following are the three main goals of integrity models:
  • Prevent unauthorized users from making modifications
  • Prevent authorized users from making improper modifications (separation of duties)
  • Maintain internal and external consistency (well-formed transaction)

Clark-Wilson addresses each of these goals in its model. Biba only addresses the first goal.

Covert channels are of two types: storage and timing. In a covert storage channel, processes are able to communicate through some type of storage space on the system. In a covert timing channel, one process relays information to another by modulating its use of system resources.

The Noninterference Model

This concept is implemented to ensure any actions that take place at a higher security level do not affect, or interfere with, actions that take place at a lower level.

The Lattice Model

A lattice is a mathematical construct that is built upon the notion of a group.The most common definition of the lattice model is "a structure consisting of a finite partially ordered set together with least upper and greatest lower bound
operators on the set."

The Brewer and Nash model

Also called the Chinese Wall model, was created to provide access controls that can change dynamically depending upon a user's previous actions. The main goal of the model is to protect against conflicts of
interest by users' access attempts.
Sort of like multi-tenancy.

Graham-Denning model 

Bell-LaPadula and Biba don't define how the security and integrity ratings are defined and modified, nor do they provide a way to delegate or transfer access rights. G-D model addresses these issues and defines a set of basic rights in terms of commands that a specific subject can execute on an object. This model has eight rules:
  • How to securely create an object, Subject(2 rules)
  • How to securely delete an object , Subject (2)
  • How to securely provide the read, grant, delete,transfer access rights (4)

The Harrison-Ruzzo-Ullman Model

The Harrison-Ruzzo-Ullman (HRU) model deals with access rights of subjects and the integrity of those rights. A subject can carry out only a finite set of operations on an object.

The Access Control Matrix Model 

This is a model in which access decisions are based on objects' ACLs and
subjects' capability tables.

Security Modes 

  • Dedicated Security Mode: All users must have …
    • Proper clearance for all information on the system
    • Formal access approval for all information on the system
    • A signed NDA for all information on the system
    • A valid need to know for all information on the system
    • All users can access all data.
  • System High-Security Mode: All users must have …
    • Proper clearance for all information on the system
    • Formal access approval for all information on the system
    • A signed NDA for all information on the system
    • A valid need to know for some information on the system
    • All users can access some data, based on their need to know.
  • Compartmented Security Mode: All users must have …
    • Proper clearance for the highest level of data classification on the system
    • Formal access approval for all information they will access on the system
    • A signed NDA for all information they will access on the system
    • A valid need to know for some of the information on the system
    • All users can access some data, based on their need to know and formal access approval.
  • Multilevel Security Mode: All users must have …
    • Proper clearance for all information they will access on the system
    • Formal access approval for all information they will access on the system
    • A signed NDA for all information they will access on the system
    • A valid need to know for some of the information on the system
    • All users can access some data, based on their need to know, clearance, and formal access approval.
In the United States, the National Computer Security Center (NCSC) is an organization within the National Security Agency (NSA) that is responsible for evaluating computer systems and products. It has a group, called the Trusted Product Evaluation Program (TPEP), that oversees the testing by approved evaluation entities of commercial products against a specific set of criteria.
The product is assigned an assurance rating based on the Orange Book (moving toward the Common Criteria).

The Orange Book

The U.S. Department of Defense developed the Trusted Computer System Evaluation Criteria (TCSEC), which is used to evaluate operating systems, applications, and different products.

TCSEC provides a classification system that is divided into hierarchical divisions of assurance levels:
  • A. Verified protection
  • B. Mandatory protection
  • C. Discretionary protection
  • D. Minimal security

Each division can have one or more numbered classes with a corresponding set of requirements that must be met for a system to achieve that particular rating. The classes with higher numbers offer a greater degree of trust and assurance. So
B2 would offer more trust than B1, and C2 would offer more trust than C1.

Seven different areas:
  • Security policy The policy must be explicit and well defined and enforced by the mechanisms within the system.
  • Identification Individual subjects must be uniquely identified.
  • Labels Access control labels must be associated properly with objects.
  • Documentation Documentation must be provided, including test, design, and specification documents, user guides, and manuals.
  • Accountability Audit data must be captured and protected to enforce accountability.
  • Life-cycle assurance Software, hardware, and firmware must be able to be tested individually to ensure that each enforces the security policy in an effective manner throughout their lifetimes.
  • Continuous protection The security mechanisms and the system as a whole must perform predictably and acceptably in different situations continuously.
These categories are evaluated independently, but the rating is a sum total of these items.

Security Levels
  • Division D: Minimal Protection
Systems that have been evaluated but fail to meet the criteria and requirements of the higher divisions.
  • Division C: Discretionary Protection
    • C1: Discretionary Security Protection
      • separation of users and information
      • access control
      • protected execution domain
      • validating the system's operational integrity. 
      • design documentation, test documentation, a facility manual, and user manuals.
    • C2: Controlled Access Protection
      • Users need to be identified individually
      • Security relevant events are audited, and records protected
      • provide resource, or object, isolation
      • object reuse concept must be clean. 
      • cannot guarantee it will not be compromised, but make it harder.
      • C2, overall, is seen as the most reasonable class for commercial applications, but the level of protection is still relatively weak.
  • Division B: Mandatory Protection
Mandatory access control is enforced by the use of security labels. The architecture is based on the Bell-LaPadula security model, and evidence of reference monitor enforcement must be available.
    • B1: Labeled Security
      • data object must contain a classification label and each subject must have a clearance label. 
      • system must compare the subject's and object's security labels 
      • The security policy is based on an informal statement
      • design specifications are reviewed and verified.
      • This rating is intended for environments that require systems to handle classified data.
    • B2: Structured Protection
      • security policy is clearly defined and documented
      • system design and implementation reviewed/tested 
      • requires more stringent authentication mechanisms 
      • Subjects and devices require labels, and the system must not allow covert channels. 
      • trusted path for logon and authentication
      • The type of environment that would require B2 systems is one that processes sensitive data that require a higher degree of security. 
    • B3: Security Domains
Note Security labels are not required until security rating B; thus, C2 does not require security labels but B1 does.
      • more granularity is provided in each protection mechanism
      • design and implementation should not provide too much complexity
      • reference monitor components must be small enough to test properly and be tamperproof. 
      • security administrator role is clearly defined, and the system must be able to recover from failures without its security level being compromised including system startup.
      • The type of environment that requires B3 systems is a highly secured environment that processes very sensitive information. It requires systems that are highly resistant to penetration.
  • Division A: Verified Protection
    • The security mechanisms between B3 and A1 are not very different, but the way the system was designed and developed is evaluated in a much more structured and stringent procedure.
    • A1: Verified Design
      • assurance of an A1 system is higher than a B3 system because of the formality in the way the A1 system was designed
      • The type of environment that would require A1 systems is the most secure of secured environments. This type of environment deals with top-secret information and cannot adequately trust anyone using the systems without strict authentication, restrictions, and auditing.
TCSEC addresses confidentiality, but not integrity. Functionality of the security mechanisms and the assurance of those mechanisms are not evaluated separately, but rather are combined and rated as a whole.

The Orange Book focuses on the operating system and the rainbow series on the other aspects.

The Trusted Network Interpretation (TNI), also called the Red Book because of the color of its cover, addresses security evaluation topics for networks and
network components.

Information Technology Security Evaluation Criteria (ITSEC)

It replaced TCSEC in 2000. ITSEC evaluates two main attributes of a system's protection mechanisms:
  • functionality
The services that are provided to the subjects (access control mechanisms, auditing, authentication, and so on) are examined and measured.When functionality is evaluated, it is tested to see if the system's protection mechanisms deliver what its vendor says they deliver.
  • Assurance 
is the degree of confidence in the protection mechanisms, and their effectiveness and capability to perform consistently. Assurance is generally tested by examining development practices, documentation, configuration management, and testing mechanisms.

Differences between ITSEC and TCSEC:
  • TCSEC bundles functionality and assurance into one rating, whereas ITSEC evaluates these two attributes separately. 
  • ITSEC was developed to provide more flexibility than TCSEC, and ITSEC addresses integrity, availability, and confidentiality, whereas TCSEC addresses only confidentiality. 
  • ITSEC also addresses networked systems, whereas TCSEC deals with stand-alone systems.
Mapping:

E0 = D
F1 + E1 = C1
F2 + E2 = C2
F3 + E3 = B1
F4 + E4 = B2
F5 + E5 = B3
F5 + E6 = A1
F6 = Systems that provide high integrity
F7 = Systems that provide high availability
F8 = Systems that provide data integrity during communication
F9 = Systems that provide high confidentiality (like cryptographic devices)
F10 = Networks with high demands on confidentiality and integrity

The Common Criteria 

Provides more flexibility by evaluating a product against a protection profile, which is structured to address a real-world security need. So while the Orange Book says, "Everyone march in this direction in this form using this path," the Common Criteria asks, "Okay, what are the threats we are facing today and what are the best ways of battling them?"
  • assigned an Evaluation Assurance Level (EAL). 
    • EAL1 Functionally tested
    • EAL2 Structurally tested
    • EAL3 Methodically tested and checked
    • EAL4 Methodically designed, tested, and reviewed
    • EAL5 Semiformally designed and tested
    • EAL6 Semiformally verified design and tested
    • EAL7 Formally verified design and tested
The protection profile provides a means for a consumer, or others, to identify specific security needs; this is the security problem to be conquered. The protection profile goes on to provide the necessary goals and protection mechanisms to achieve the required level of security.


Like other evaluation criteria before it, the Common Criteria works to answer two basic questions about products being evaluated: what does its security mechanisms do (functionality), and how sure are you of that (assurance)?

Certification is the comprehensive technical evaluation of the security components and their compliance for the purpose of accreditation. The goal of a certification process is to ensure that a system, product, or network is right for the customer's purposes.

Accreditation is the formal acceptance of the adequacy of a system's overall security and functionality by management. The certification information is presented to management and once satisfied with the system's overall security management makes a formal accreditation statement.

How to set up a security program:

  • Plan and Organize
    • Establish management commitment
    • Establish oversight steering committee
    • Assess business drivers
    • Carry out a threat profile on the organization
    • Carry out a risk assessment
    • Develop security architectures at an organizational, application, network, and component level
    • Identify solutions per architecture level
    • Obtain management approval to move forward
  • Implement
    • Assign roles and responsibilities
    • Develop and implement security policies, procedures, standards, baselines, and guidelines
    • Identify sensitive data at rest and in transit
    • Implement the following blueprints:
      • Asset identification and management
      • Risk management
      • Vulnerability management
      • Compliance
      • Identity management and access control
      • Change control
      • Software development life cycle
      • Business continuity planning
      • Awareness and training
      • Physical security
      • Incident response
    • Implement solutions (administrative, technical, physical) per blueprint
      • Develop auditing and monitoring solutions per blueprint
      • Establish goals, service level agreements (SLAs), and metrics per blueprint
  • Operate and Maintain
    • Follow procedures to ensure all baselines are met in each implemented blueprint
    • Carry out internal and external audits
    • Carry out tasks outlined per blueprint
    • Manage service level agreements per blueprint
  • Monitor and Evaluate
    • Review logs, audit results, collected metric values, and SLAs per blueprint
    • Assess goal accomplishments per blueprint
    • Carry out quarterly meetings with steering committee
    • Develop improvement steps and integrate into the Plan and Organize phase

The Zachman framework is a two-dimensional model that uses six basic communication interrogatives (What, How, Where,Who, When, and Why) intersecting with different levels (Planner, Owner, Designer, Builder, Implementer, and Worker) to give a holistic view of the enterprise.

Here is a helpful hint for row Descriptions ( = means is equal to :-) ):
  • Scope=Contextual = Planner
  • Business Model= Conceptual = Owner
  • System Model = Logical = Designer
  • Technology Model = Physical = Builder
  • Detailed Representations = Detailed = Sub Contractor
Column Descrriptions

What(data), Where(Network), When(time), Why(Motivation), Who(People) and How(Function).

See my Enterprise Architecture blog post for a discussion of the frameworks including Zachman.

When an enterprise security architecture is being developed, the following items must be understood and followed:
  • strategic alignment, process enhancement, business enablement, and security effectiveness.
Strategic alignment means the business drivers and the regulatory and legal requirements are being met by the security architecture.



SABSA
A group developed the Sherwood Applied Business Security Architecture (SABSA), as shown in the following table, which is based on the Zachman framework. When building a security architecture, you can visit www.sabsainstitute.org/ home.aspx to learn more about this approach.

A Few Threats

  • Maintenance Hooks
  • Time-of-Check/Time-of-Use Attacks
Specific attacks can take advantage of the way a system processes requests and performs tasks. A time-of-check/timeof-use (TOC/TOU) attack deals with the sequence of steps a system uses to complete a task. This type of attack takes
advantage of the dependency on the timing of events that take place in a multitasking operating system. An example of a TOC/TOU attack is if process 1 validates the authorization of a user to open a noncritical text file and
process 2 carries out the open command. If the attacker can change out this noncritical text file with a password file while process 1 is carrying out its task, she has just obtained access to this critical file. (It is a flaw within the code that allows this type of compromise to take place.)

  • Buffer Overflows


Tips
- Two systems can have the exact same hardware, software components, and applications, but provide different levels of protection because of the different security policies and security models the two systems were built upon.
-  A CPU contains a control unit, which controls the timing of the execution of instructions and data, and an ALU, which performs mathematical functions and logical operations.
-  Most systems use protection rings. The more privileged processes run in the lower-numbered rings and have access to all or most of the system resources. Applications run in higher-numbered rings and have access to a smaller amount of resources.
-  Operating system processes are executed in privileged or supervisor mode, and applications are executed in user mode, also known as "problem state."
-  Secondary storage is nonvolatile and can be a hard drive, CD-ROM drive, floppy drive, tape backup, or a jump drive.
-  Virtual storage combines RAM and secondary storage so the system seems to have a larger bank of memory.
-  A deadlock situation occurs when two processes are trying to access the same resource at the same time.
-  Security mechanisms can focus on different issues, work at different layers, and vary in complexity.
-  The more complex a security mechanism is, the less amount of assurance it can usually provide.
-  Not all system components fall under the trusted computing base (TCB), which includes only those system components that enforce the security policy directly and protect the system. These components are within the security perimeter.
-  Components that make up the TCB are hardware, software, and firmware that provide some type of security protection.
-  A security perimeter is an imaginary boundary that has trusted components within it (those that make up the TCB) and untrusted components outside it.
-  The reference monitor concept is an abstract machine that ensures all subjects have the necessary access rights before accessing objects. Therefore, it mediates all accesses to objects by subjects.
-  The security kernel is the mechanism that actually enforces the rules of the reference monitor concept.
-  The security kernel must isolate processes carrying out the reference monitor concept, must be tamperproof, must be invoked for each access attempt, and must be small enough to be properly tested.
-  A security domain is all the objects available to a subject.
-  Processes need to be isolated, which can be done through segmented memory addressing, encapsulation of objects, time multiplexing of shared resources, naming distinctions, and virtual mapping.
-  The level of security a system provides depends upon how well it enforces the security policy.
-  A multilevel security system processes data at different classifications (security levels), and users with different clearances (security levels) can use the system.
-  Processes should be assigned least privilege so they have just enough system privileges to fulfill their tasks and no more.
-  Some systems provide security at different layers of their architectures, which is called layering. This separates the processes and provides more protection for them individually.
-  Data hiding occurs when processes work at different layers and have layers of access control between them. Processes need to know how to communicate only with each other's interfaces.
-  A security model maps the abstract goals of a security policy to computer system terms and concepts. It gives the
security policy structure and provides a framework for the system.
-  A closed system is often proprietary to the manufacturer or vendor, whereas the open system allows for more interoperability.
-  The Bell-LaPadula model deals only with confidentiality, while the Biba and Clark-Wilson models deal only with integrity.
-  A state machine model deals with the different states a system can enter. If a system starts in a secure state, all state transitions take place securely, and the system shuts down and fails securely, the system will never end up in an insecure state.
-  A lattice model provides an upper bound and a lower bound of authorized access for subjects.
-  An information flow security model does not permit data to flow to an object in an insecure manner.
-  The Bell-LaPadula model has a simple security rule, which means a subject cannot read data from a higher level (no read up). The *-property rule means a subject cannot write to an object at a lower level (no write down). The strong star property rule dictates that a subject can read and write to objects at its own security level.
-  The Biba model does not let subjects write to objects at a higher integrity level (no write up), and it does not let subjects read data at a lower integrity level (no read down). This is done to protect the integrity of the data.
-  The Bell-LaPadula model is used mainly in military systems. The Biba and Clark-Wilson models are used in the commercial sector.
-  The Clark-Wilson model dictates that subjects can only access objects through applications. This model also illustrates how to provide functionality for separation of duties and requires auditing tasks within software.
-  If a system is working in a dedicated security mode, it only deals with one level of data classification, and all users must have this level of clearance to be able to use the system.
-  Compartmented and multilevel security modes enable the system to process data classified at different classification levels.
-  Trust means that a system uses all of its protection mechanisms properly to process sensitive data for many types of users. Assurance is the level of confidence you have in this trust and that the protection mechanisms behave properly in all circumstances predictably.
-  The Orange Book, also called Trusted Computer System Evaluation Criteria (TCSEC), was developed to evaluate systems built to be used mainly by the military. Its use was expanded to evaluate other types of products.
-  In the Orange Book, D classification means a system provides minimal protection and is used for systems that were evaluated but failed to meet the criteria of higher divisions.
-  In the Orange Book, the C division deals with discretionary protection, and the B division deals with mandatory protection (security labels).
-  In the Orange Book, the A classification means the system's design and level of protection are verifiable and provide the highest level of assurance and trust.
-  In the Orange Book, C2 requires object reuse protection and auditing.
-  In the Orange Book, B1 is the first rating that requires security labels.
-  In the Orange Book, B2 requires security labels for all subjects and devices, the existence of a trusted path, routine covert channel analysis, and the provision of separate administrator functionality.
-  The Orange Book deals mainly with stand-alone systems, so a range of books were written to cover many other topics in security. These books are called the Rainbow Series.
-  ITSEC evaluates the assurance and functionality of a system's protection mechanisms separately, whereas TCSEC combines the two into one rating.
-  The Common Criteria was developed to provide globally recognized evaluation criteria and is in use today. It combines sections of TCSEC, ITSEC, CTCPEC, and the Federal Criteria.
-  The Common Criteria uses protection profiles and ratings from EAL1 to EAL7.
-  Certification is the technical evaluation of a system or product and its security components. Accreditation is management's formal approval and acceptance of the security provided by a system.
-  A covert channel is an unintended communication path that transfers data in a way that violates the security policy. There are two types: timing and storage covert channels.
-  A covert timing channel enables a process to relay information to another process by modulating its use of system resources.
-  A covert storage channel enables a process to write data to a storage medium so another process can read it.
-  A maintenance hook is developed to let a programmer into the application quickly for maintenance. This should be removed before the application goes into production or it can cause a serious security risk.
-  An execution domain is where instructions are executed by the CPU. The operating system's instructions are executed in a privileged mode, and applications' instructions are executed in user mode.
-  Process isolation ensures that multiple processes can run concurrently and the processes will not interfere with each other or affect each other's memory segments.
-  The only processes that need complete system privileges are located in the system's kernel.
-  TOC/TOU stands for time-of-check/time-of-use. This is a class of asynchronous attacks.
-  The Biba model addresses the first goal of integrity, which is to prevent unauthorized users from making modifications.
-  The Clark-Wilson model addresses all three integrity goals: prevent unauthorized users from making modifications, prevent authorized users from making improper modifications, and maintain internal and external consistency.
-  In the Clark-Wilson model, users can only access and manipulate objects through programs. It uses access triple,which is subject-program-object.


These are notes collected from various sources.

Sunday, November 18, 2012

Security: OWASP Cheat Sheets summary

REST Security Cheat Sheet

  • It is common for REST services to allow multiple response types (e.g. application/xml or application/json, and the client specifies the preferred order of response types by the Accept header in the request. Do NOT simply copy the Accept header to the Content-type header of the response. Reject the request (ideally with a 406 Not Acceptable response) if the Accept header does not specifically contain one of the allowable types.
  • It is important for the service to properly restrict the allowable verbs(GET, POST etc) such that only the allowed verbs will work, all others return a proper response code (for example, a 403 Forbidden). This is because someone can use http HEAD with that URL and we won't be able to check.
  • Authentication for a REST-based service should not take place by passing the user ID and password in path elements of the URL. URL's are commonly cached

Business Requirements

  • Business Model

  • Data Essentials

  • End-Users

  • Partners

  • Administrators

  • Regulations

Infrastructure Requirements
  • Network
  • Systems
  • Infrastructure Monitoring
  • Virtualization and Externalization

Application Requirements
  • Environment
  • Data Processing
  • Access
  • Application Monitoring
  • Application Design
Security Program Requirements
  • Operations
         - identifying and addressing vulnerabilities
  • Change Management
  • Software Development
  • Corporate
            - employee
            - governance requirements

Web Service Security Cheat Sheet

XML Denial of Service Protection
XML Denial of Service is probably the most serious attack against web services. So the web service must provide the following validation:
  • Rule - Validation against recursive payloads
  • Rule - Validation against oversized payloads
  • Rule - Protection against XML entity expansion
  • Rule - Validating against overlong element names. If you are working with SOAP-based Web Services, the element names are those SOAP Actions.
Input Validation Cheat Sheet

Some white list validators have also been predefined in various open source packages that you can leverage. Two packages that provide this are:
It is recommended that you use ESAPI to assist with your input validation needs, rather than writing your own validation routines. The OWASP Enterprise Security API (ESAPI) project has predefined validators defined in the org.owasp.esapi.Validator interface and implemented in the DefaultValidator reference implementation. These include:
  • getValidDate()
  • getValidSafeHTML()
  • getValidInput()
  • getValidNumber()
  • getValidFileName()
  • getValidRedirectLocation()

Cryptography

Relevant COBIT Topics
DS5.18 – Cryptographic key management

Cryptographic systems can provide one or more of the following four services:
  • Authentication:SSL Certs
  • Non-Repudiation:digitally signing
  • Confidentiality
  • Integrity:Cryptographic hashes


Cryptographic Algorithms

  • Asymmetric (also Public/Private Key Cryptography)

PGP and SSL are prime examples of a systems implementing asymmetric cryptography, using the RSA(asym cipher) or other algorithms. Common Asymmetric signature scheme is DSA ( Digital Signature Algorithm)
  • Symmetric

. Common examples of symmetric algorithms are DES, 3DES and AES. DES should no longer be used.

  • Hashes

Hash functions take some data (and possibly a key or password) and generate a unique hash or checksum. MD5 and SHA-1 are common hashing algorithms used today. These algorithms are considered weak (see below) and are likely to be replaced after a process similar to the AES selection. New implementations should consider using SHA-256 instead of these weaker algorithms.
Message Authentication Codes ( MAC), uses keys and are used as hash functional as well.

Use good sources of randomness. JCE as one.


Key Exchange Algorithms

Lastly, we have key exchange algorithms (such as Diffie-Hellman for SSL). These allow use to safely exchange encryption keys with an unknown party. 

Stream ciphers, such as RC4, are vulnerable due to a property of stream ciphers. If you use the same key to “protect” two different documents, the keystream drops out when you XOR the two documents together, leaving the plaintexts XOR’d together. The two plain text documents can be recovered using frequency analysis. 











Specific algorithms to avoid:

MD5 has recently been found less secure than previously thought.
SHA-0 has been conclusively broken.
SHA-1 has been reduced in strength and we encourage a migration to SHA-256, which implements a larger key size

DES was once the standard crypto algorithm for encryption; a normal desktop machine can now break it. AES is the current preferred symmetric algorithm.



Recommendations

Symmetric:
·       Key sizes of 128 bits (standard for SSL) are sufficient for most applications
·       Consider 168 or 256 bits for secure systems such as large financial transactions
Asymmetric:
·       Key sizes of 1280 bits are sufficient for most personal applications
·       1536 bits should be acceptable today for most secure applications
·       2048 bits should be considered for highly protected applications.
Hashes:
·       Hash sizes of 128 bits (standard for SSL) are sufficient for most applications
·       Consider 168 or 256 bits for secure systems, as many hash functions are currently being revised (see above).

  • SSL 2.0 should never be used.
  • multiple domain certificates or enhanced wildcard certificates can be used to provide a listing of multiple names in a certificate.
  • TLS has renegotiation vulnerability which most browsers have corrected.
  • NIST SP 800-52 recommends to use TLS 1.0 with RSA or DSA, with ephemeral Diffie Hellman, 3DES or AES and SHA1 (or SHA256) for integrity protection. MD5 and RC4 are disallowed.




Cryptographic Storage Cheat Sheet

  • 2.3.1 Rule - Only store sensitive data that you need
  • 2.3.2 Rule - Only use strong cryptographic algorithms
    Symmetric Key
             Currently, there exist three FIPS-approved symmetric key algorithms for encryption: Advanced Encryption Standard    (AES), Triple-DES, and Skipjack. AES is the FIPS-Approved symmetric encryption algorithm of choice.

             Asymmetric Key
FIPS 186-3 Digital Signature Standard (DSS) (DSA, RSA, and ECDSA algorithms)
On June 10, 2009, NIST announced the adoption of FIPS 186-3, Digital Signature Standard (DSS), which is a revision of FIPS 186-2. The FIPS specifies three techniques for the generation and verification of digital signatures:

Digital Signature Algorithm (DSA), RSA (as specified in ANSI X9.31 (RSA)), and Elliptic Curve DSA (ECDSA; as specified in ANSI X9.62).

Secure Hash Standard (SHS)
(SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 algorithms)
The Secure Hash Algorithms (SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512) are specified in FIPS 180-3 dated October 2008, Secure Hash Standard (SHS).


Random Number Generators (RNG)
The algorithms for generating approved random numbers are referenced in FIPS 140-2 Annex C.


Message Authentication (MAC)
Block Cipher-based MAC Algorithm (CMAC)
The CMAC algorithm is specified in Special Publication 800-38B dated May 2005, Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication. CMAC can be considered a mode of operation of the block cipher because it is based on an approved symmetric key block cipher, such as the Advanced Encryption Standard (AES) algorithm currently specified in Federal Information Processing Standard (FIPS) Pub. 197. CMAC is also an approved mode of the Triple Data Encryption Algorithm (TDEA).

Keyed-Hash Message Authentication Code (HMAC)
The Keyed-Hash Message Authentication Code (HMAC) is specified in FIPS 198 dated March 6, 2002, Keyed-Hash Message Authentication Code (HMAC). This algorithm utilizes the Secure Hash Algorithms as an underlying primitive.


  • 2.3.2.1 Rule - Ensure that random numbers are cryptographically strong
Ensure that all random numbers, random file names, random GUIDs, and random strings are generated in a cryptographically strong fashion. Also ensure that random algorithms are seeded with sufficient entropy.

  • 2.3.2.2 Rule - Only use widely accepted implementations of cryptographic algorithms
  • 2.3.2.3 Rule - Prefer authenticated encryption modes
Use cryptographic cipher modes that offer both confidentiality and authenticity. Recommended modes include counter with CBC-MAC (CCM) mode and Galois/counter mode (GCM). These authenticated encryption (AE) modes resist padding oracle attacks which can be used in many cases to recover plaintext from ciphertext without knowledge of the encryption key.

  • 2.3.3 Rule - Store the hashed and salted value of passwords
  • 2.3.4 Rule - Ensure that the cryptographic protection remains secure even if access controls fail
  • 2.3.5 Rule - Ensure that any secret key is protected from unauthorized access
  • 2.3.5.1 Rule - Define a key lifecycle
  • 2.3.5.2 Rule - Store unencrypted keys away from the encrypted data
  • 2.3.5.3 Rule - Use independent keys when multiple keys are required
  • 2.3.5.4 Rule - Protect keys in a key vault
  • 2.3.5.5 Rule - Document concrete procedures for managing keys through the lifecycle
  • 2.3.5.6 Rule - Build support for changing keys periodically
  • 2.3.5.7 Rule - Document concrete procedures to handle a key compromise
  • 2.3.5.8 Rule - Rekey data at least every one to three years
  • 2.3.6 Rule - Follow applicable regulations on use of cryptography
  • 2.3.6.1 Rule - Under PCI DSS requirement 3, you must protect cardholder data
PCI DSS requirement 3 covers secure storage of credit card data. This requirement covers several aspects of secure storage including the data you must never store but we are covering Cryptographic Storage which is covered in requirements 3.4, 3.5 and 3.6 as you can see below:
  • 3.4 Render PAN (Primary Account Number), at minimum, unreadable anywhere it is stored
  • 3.5 Protect any keys used to secure cardholder data against disclosure and misuse
  • 3.6 Fully document and implement all key-management processes and procedures for cryptographic keys used for encryption of cardholder data
Requirement 3.6 mandates that key management processes within a PCI compliant company cover 8 specific key lifecycle steps:
  • 3.6.1 Generation of strong cryptographic keys

  • 3.6.2 Secure cryptographic key distribution
The method used to distribute keys must be secure to prevent the theft of keys in transit. The use of a protocol such as Diffie Hellman can help secure the distribution of keys, the use of secure transport such as SSLv3, TLS and SSHv2 can also secure the keys in transit.
  • 3.6.3 Secure cryptographic key storage
The secure storage of encryption keys including KEK's has been touched on in our description of requirement 3.5 (see above).
  • 3.6.4 Periodic cryptographic key changes
The PCI DSS standard mandates that keys used for encryption must be rotated at least annually.
  • 3.6.5 Retirement or replacement of keys as deemed necessary when the integrity of the key has been weakened or keys are suspected of being compromised
  • 3.6.6 Split knowledge and establishment of dual control of cryptographic keys
  • 3.6.7 Prevention of unauthorized substitution of cryptographic keys
  • 3.6.8 Requirement for cryptographic key custodians to sign a form stating that they understand and accept their key-custodian responsibilities

SSL/TLS

TLS version 1.0 and SSL 3.0 are very similar. SSL 3.1 is identical to TLS 1.0

Handshake process
  • TLS begins by client initiating the handshakre protocol with hello message that includes protocol version, session id, cipher suite, compression method and a random number.
  • server responds with hello msg that includes protocol version, session id, cipher suite, compression method and a random number.
  • server then sends it cert and msg indicating it finished with hello msg.
  • client responds with a key exchange msg. for instance in the case of TLS_RSA_WITH_RC4_CBC_MD5, the client generates a 48 byte premaster secret and encrypts it with the servers RSA public key.
    • 48 byte includes 2 bytes for client version and 46 random bytes 
  • server decrypts the key exchange msg and verifies first two bytes are same as earlier client version.
  • Now both client and server use random numbers exchanged and pre master secret with a pseudo random function (PRF) to generate master secret. 
    • master secret is 48 bytes long. It has 3 128 bit keys; one for keyed MD5 (MAC), one for symmetric(RC4) and one as initialization vector for symmetric algorithm.
  •  client/server send handshake finished to each other.
  • now session keys based on master secret are used for remainder of TLS session.

TLS benefits
  • integrity guarantees
  • replay prevention
Online Certificate status protocol (OCSP) responder to check for certificate revocation status.

Crypto Module
  • components that implement crypto algos
  • components that call and manage crypto functions
  • physical container around the above two.

  • For FIPS 140-2:
    • SSL must be disabled and TLS must be used.


  • Set the "secure" flag for the cookie to avoid sending in http mode ( versus https)
  • Strict transport security will provide a server side control to instruct browsers to use https only.


Database Encryption

Transparent Data Encryption is a new feature in SQL Server 2008 which implements database-level encryption complementing the row-level encryption which is currently available in SQL Server 2005. This protects database access, either directly or by restoring a database backup on another SQL Server instance.


  • Setting up encryption on the server. To do that, we create the database master key on the master database


USE master
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'mY_P@$$w0rd'


  • Then, we create the server-based certificate which will be used to encrypt the database


CREATE CERTIFICATE NorthwindCert
WITH SUBJECT = 'My DEK Certificate for Northwind database'


  • We will then set the encryption for the Northwind database by creating a database encryption key and password using the certificate we just created.


USE Northwind
GO
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_128
ENCRYPTION BY SERVER CERTIFICATE NorthwindCert
GO

  • The encryption algorithm choice is yours, since a few different options exist.  For guidance on selecting an encryption algorithm on SQL Server, check out this Microsoft TechNet article.  After creating the database encryption key, we'll enable encryption on the database level.


ALTER DATABASE Northwind
SET ENCRYPTION ON

  • Let's backup the encrypted Northwind database this time but using a different filename.


BACKUP DATABASE Northwind
TO DISK = 'C:\Northwind_encrypted.bak'
WITH INIT, STATS = 10

  • The encrypted backup would take a bit longer than the unencrypted backup. If you open the encrypted database backup and search for the string 'A r i a   C r u z' which we searched for earlier, you will no longer find it. 



Session Management

  • Set secure and HttpOnly flags for session cookies. Send CSRF tokens with forms.
  • Throttle requests from a particular user.



Authentication  & Authorization

Relevant COBIT Topics: DS5 – All sections should be reviewed.

  • username and password is suitable for low value systems such as blogs and forums, SMS challenge response is suitable for low value e-commerce systems (in 2005), whilst transaction signing is suitable for high value systems such as high value e-commerce
  • HTTP 1.1 Digest authentication uses a challenge response mechanism, which is reasonably safe for low value applications.
  • Certificate revocation with self-issued certificates is almost impossible in extranet environments.
  • Soft certificates (also known as client-side certificate authentication) are a little stronger than passwords, but suffer from the same problems as passwords and any authentication method which automatically processes credentials.
  • Challenge Response: Challenge response tokens work by taking a value (challenge) from the system and processing them in a cryptographically secure fashion to derive a result.
  • Transaction signing is performed by offline challenge response calculators. The user will be presented with various items to enter into the calculator, and it will calculate a response based upon these inputs. This is the strongest form of authentication as the user has to enter the transaction details – any other transaction will fail to produce a suitable response. This type of authentication has strong non-repudiation properties, is robust against man in the middle attacks, cannot be replayed, and is robust against differing transaction limits.
    For the best effect, at least the following should be stirred into the challenge:
    ·       Reference ID
    ·       From account
    ·       Amount of the transaction

  • Use decent one-way hash algorithm, such as AES-128 in digest mode or SHA-256 bit.
  • Check that the app has a delay between the user submitting the credential and a success or failure is reported. A delay of three seconds can make automated brute force attacks almost unfeasible. A progressive delay (3 seconds then 15 then 30 then disconnect) can make casual brute force attacks completely ineffective
  • Event correlation software such as Simple Event Correlator (SEC) can be used to define rules to parse through the logs and generate alerts based on aggregated events. This could also be done by adding a Snort rule for alerting on HTTP Authorization Failed error messages going out from your web server to the user, and SEC can then be used to aggregate and correlate these alerts.
  • Note: Any web site that is mandated or legally required to be accessible must not use CAPTCHA’s. if you can't:
    • You have to provide alternate means of registration etc.
    • deter the use of automated sign ups by using the “no follow” tag. Search engines will ignore hyperlinks and pages with this tag set, immensely devaluing the use of link spamming




Session Management
  • Relevant COBIT Topics
    • PO8 – All sections should be reviewed
    • PO8.4 – Privacy, Intellectual proeprty and data flow
  • The session ID value must provide at least 64 bits of entropy (if a good PRNG is used, this value is estimated to be half the length of the session ID).
  • the “Secure” cookie attribute (see below) must be used to ensure the session ID is only exchanged through an encrypted channel. The usage of an encrypted communication channel also protects the session against some session fixation attacks where the attacker is able to intercept and manipulate the web traffic to inject (or fix) the session ID on the victims web browser [4].
  • Web applications should never switch a given session from HTTP to HTTPS, or viceversa, as this will disclose the session ID in the clear through the network
  • Web applications should not mix encrypted and unencrypted contents (HTML pages, images, CSS, Javascript files, etc) on the same host (or even domain - see the “domain” cookie attribute), as the request of any web object over an unencrypted channel might disclose the session ID
  • Web applications should make use of “HTTP Strict Transport Security (HSTS)” (previously called STS) to enforce HTTPS connections.
  • The “Secure” cookie attribute instructs web browsers to only send the cookie through an encrypted HTTPS (SSL/TLS) connection.
  • Forcing the web application to only use HTTPS for its communication (even when port TCP/80, HTTP, is closed in the web application host) does not protect against session ID disclosure if the “Secure” cookie has not been set - the web browser can be deceived to disclose the session ID over an unencrypted HTTP connection. The attacker can intercept and manipulate the victim user traffic and inject an HTTP unencrypted reference to the web application that will force the web browser to submit the session ID in the clear.
  • The “HttpOnly” cookie attribute instructs web browsers not to allow scripts (e.g. JavaScript or VBscript) an ability to access the cookies via the DOM document.cookie object. This session ID protection is mandatory to prevent session ID stealing through XSS attacks.
  • The “Domain” cookie attribute instructs web browsers to only send the cookie to the specified domain and all subdomains. If the attribute is not set, by default the cookie will only be sent to the origin server. The “Path” cookie attribute instructs web browsers to only send the cookie to the specified directory or subdirectories (or paths or resources) within the web application. If the attribute is not set, by default the cookie will only be sent for the directory (or path) of the resource requested and setting the cookie.
    • It is recommended to use a narrow or restricted scope for these two attributes. In this way, the “Domain” attribute should not be set (restricting the cookie just to the origin server) and the “Path” attribute should be set as restrictive as possible to the web application path that makes use of the session ID.
  • it is recommended not to mix web applications of different security levels on the same domain. Vulnerabilities in one of the web applications would allow an attacker to set the session ID for a different web application on the same domain by using a permissive “Domain” attribute (such as “example.com”) which is a technique that can be used in session fixation attacks
  • Although the “Path” attribute allows the isolation of session IDs between different web applications using different paths on the same host, it is highly recommended not to run different web applications (especially from different security levels or scopes) on the same host. Other methods can be used by these applications to access the session IDs, such as the “document.cookie” object. Also, any web application can set cookies for any path on that host.
  • Cookies are vulnerable to DNS spoofing/hijacking/poisoning attacks, where an attacker can manipulate the DNS resolution to force the web browser to disclose the session ID for a given host or domain.
  •  If a cookie presents the “Max-Age” (that has preference over “Expires”) or “Expires” attributes, it will be considered a persistent cookie and will be stored on disk by the web browser based until the expiration time. Typically, session management capabilities to track users after authentication make use of non-persistent cookies. 
  •  The session ID must be renewed or regenerated by the web application after any privilege level change within the associated user session.
    •  The session ID regeneration is mandatory to prevent session fixation attacks [3], where an attacker sets the session ID on the victims user web browser instead of gathering the victims session ID
  • All sessions should implement an absolute timeout, regardless of session activity. This timeout defines the maximum amount of time a session can be active, closing and invalidating the session upon the defined absolute period 
  •  Web applications should focus on detecting anomalies associated to the session ID, such as its manipulation. The OWASP AppSensor Project [7] provides a framework and methodology to implement built-in intrusion detection capabilities within web applications focused on the detection of anomalies and unexpected behaviors, in the form of detection points and response actions.
  • bind the session ID to other user or client properties, such as the client IP address, User-Agent, or client-based digital certificate
    • A skilled attacker can bypass these controls by reusing the same IP address assigned to the victim user by sharing the same network (very common in NAT environments, like Wi-Fi hotspots), by using the same outbound web proxy (very common in corporate environments), or by modifying his User-Agent to look exactly as the victim users does.
    • Can also tie the session to a particular browser by using a hash of the server-side IP address (REMOTE_ADDR) and if the header exists, PROXY_FORWARDED_FOR. Note that you shouldn’t use the client-forgeable headers, but take a hash of them. If the new hash doesn’t match the previous hash, then there is a high likelihood of session replay.
  •  In situations where the web application source code is not available or cannot be modified or requires complete redesign, or to complement the web application defenses, and with the goal of keeping the web application as secure as possible, it is recommended to use external protections such as Web Application Firewalls (WAFs) that can mitigate the session management threats
  •  The open-source ModSecurity WAF, plus the OWASP Core Rule Set [6], provide capabilities to detect and apply security cookie attributes, countermeasures against session fixation attacks, and session tracking features to enforce sticky sessions.
  •  Form data should not contain hidden fields – if it is hidden, it probably needs to be protected and only available on the server side. However, hidden fields can (and should) be used for sequence protection and to prevent brute force pharming attacks. 

  • storing all state within each request(in contrast to storing in session), leads to extensive use of hidden fields and extra database queries to avoid server-side session management, and is vulnerable to replay and request forgery attacks, as well as producing complex code.
  • Some frameworks use shared areas of the web server’s disk to store session data. In particular, PHP uses /tmp on Unix and c:\windows\temp on Windows by default. These areas provide no protection for session data, and may lead to compromise.
  • Page and Form Tokens
    • Page specific tokens or "nonces" may be used in conjunction with session specific tokens to provide a measure of authenticity when dealing with client requests.
    • Page tokens are often stored in cookies or query strings and should be completely random. It is possible to avoid sending session token information to the client entirely through the use of page tokens, by creating a mapping  
  • If a session handler issues tokens which are predictable, an attacker does not need to capture session variables from the remote users – they can simply guess.
  • Consider using "booby trapped" session tokens that will detect a brute force attack.Then: 
    • Go slow or ban the originating IP address (which can be troublesome as more and more ISPs are using transparent caches to reduce their costs. Because of this: always check the "proxy_via" header)
    • Apache web server modules, such as mod_dosevasive and mod_security, that could be used for this kind of protection. Although mod_dosevasive is used to lessen the effect of DoS attacks, it could be rewritten for other purposes as well 
  • Associate the session ID, IP address, and other attributes from the user’s headers in a hash. If the hash changes, and more than one of the details has changed, it is likely that a session fixation attack has occurred.
  • Use Brutus to check if you can brute force a session and resume it. If yes, then session id requires greater entropy.


 Data Validation Strategies
There are four strategies for validating data, and they should be used in this order:
  • Accept known good
  • Reject known bad. If you don't expect to see characters such as %3f or JavaScript or similar, reject strings containing them:
  • Sanitize: Eliminate or translate characters (such as to HTML entities or to remove quotes) in an effort to make the input "safe":
  • No validation: not a strategy at all :-) 
Tips:
  • Code containing hidden fields should be rejected during code reviews.
  • Some strings may be received in encoded form. It is essential to send the correct locale to the user so that the web server and application server can provide a single level of canoncalization prior to the first use.
  • Do not use getReader() or getInputStream() as these input methods do not decode encoded strings. If you need to use these constructs, you must decanoncalize data by hand.
  • Relevant COBIT Topics
    • DS11 – Manage Data – All sections should be reviewed
    • DS11.9 – Data processing integrity
    • DS11.20 – Continued integrity of stored data


This attack, uses a weakness in the HTTP protocol definition to inject hostile data into the user’s browser. Klein describes the following classes of attacks:
·       Cross-Site Scripting (XSS)
·       Web Cache Poisoning (defacement)
·       Cross User attacks (single user, single page, temporary defacement)
·       Hijacking pages
·       Browser cache poisoning
In HTTP, the headers and body are separated by a double carriage return line feed sequence. If the attacker can insert data into a header, such as the location header (used in redirects) or in the cookie, and if the application does not protect against CRLF injection, it is quite likely that the application will be vulnerable to HTTP Response Splitting. The attack injects two responses (thus the name), where the first response is the attacker’s payload, and the second response containing the rest of the user’s actual output, is usually ignored by the web server. 

Java generally does not contain the ability to evaluate dynamic JSPs. However, there are two exceptions to this:
·       Dynamic JSP inclusion (<jsp:include ...>)
·       Using a third party JSP eval taglibs.
·       Portals and other community-based software often require the evaluation of dynamic code for templates and skinning. If the portal software requires dynamic includes and dynamic code execution, there is a risk of Java or JSP code injection.

To combat this, the primary defenses are to
·       Always prefer static include ( <% include ... %> )
·       Not allow the inclusion of files outside of the server by using Java 2 Security policies
·       Establish firewall rules to prevent outbound Internet connectivity
·       Ensure that code does not interpret user data without prior validation.

Generally, dynamic inclusion and dynamic code evaluation should be frowned upon.