• No results found

Integrating security into the Java EE development process Doing it right from the start

N/A
N/A
Protected

Academic year: 2021

Share "Integrating security into the Java EE development process Doing it right from the start"

Copied!
49
0
0

Loading.... (view fulltext now)

Full text

(1)

Eelco Klaver CISSP ([email protected])

LinkedIn: http://www.linkedin.com/in/eklaver Twitter: @econsulting_nl

Co-founder of Know IT knowledge network

Integrating security into the

Java EE development process

(2)

DOING SECURITY RIGHT FROM THE START!

If cars where build like

applications…

• Cars would have no airbags, mirrors, seat belts, doors, roll-bars, side-impact bars, or locks, because no-one had

asked for them. But they would have six cup holders.

• Car design would assume that safety is a function of road design and drivers are considerate.

• Not all components would be bolted together securely and many of them would not be built to tolerate even the slightest abuse.

• Safety tests would assume frontal impact only. Cars would not be tested for stability in emergency maneuvers, brake effectiveness, side impact and resistance to theft.

• The only warning indicator would be large quantities of smoke and flame in the cab.

(3)

Goal of the presentation

• Create an awareness that Java EE security does not

solve all security problems.

• Present a number of security activities that should be

added to your software development process in order to

be able to create secure applications.

(4)

Contents

• Java EE – Security out of the box

• Consequences and impact

• Adding security to the software development process

– Requirements – Design – Coding – Test – Deployment

• Conclusions

• Questions

(5)

Java EE – Introduction

• What is Java EE

– Java Standard Edition – Programming languages and API’s – Platform specification

– Set of API’s for security, transaction management, messaging, etc.

• Different vendors of application servers

– IBM WebSphere – Oracle WebLogic – Redhat JBoss – Oracle Glassfish – Etc.

(6)

Java EE – Security out of the box

• Java EE Specification: Security Architecture goals

– So: Developers do not need to know about security

– So: Administrators take care of security at the end

DOING SECURITY RIGHT FROM THE START!

Isolation: The Java EE platform should be able to perform authentication and access control according to instructions established by the Deployer using deployment attributes, and managed by the System Administrator.

Transparency: Application Component Providers should not have to know anything about security to write an application.

(7)

Java EE – Security out of the box

• Java EE security

– Simplified, unified security model

• Standard authentication

• Role-based authorization on URL resources and EJB method level

– Based on users, groups and roles

– Authentication based on HTTP Basic Authentication, SSL Mutual Authentication, Form Based Authentication.

– Session management and support for single sign on access to application services

– Access control based on permissions approach

• Both declarative and programmatic

• Authorization Model

– Security roles specified by application developer.

– Deployer maps roles to identities in operational environment.

(8)

Java EE – Security is not enough

• But it lacks important features

– Only access control on web resources and EJB methods – No instance-based or segment-based authorization

– No protection against XSS, injection flaws, DoS, etc. – Limited unit test possibilities of Java EE security – Standardized audit logging

– No support for user management API – Etc.

• Java EE Specification: Security Architecture non-goals

– Not just administrators, but developers must know about security

DOING SECURITY RIGHT FROM THE START!

This specification does not provide any warranty or assurance of the effective security of a Java EE product.

(9)

Java EE – The verdict on existing apps

Java-EE applications were the most

prevalent in the Cast Report on Application Software Health, taking up 46 percent of all applications, and also had the most problems on average, while Cobol and SAP's ABAP had the fewest.

These factors were rolled up into a score called "technical debt," the theoretical cost of repairing each line of code (at a rate of $75 per hour) that doesn't follow good practices, as Computerworld notes. Java EE's technical debt was pegged at $5.42

per line of code while Cobol impressed

with a score of $1.26. Oracle Forms and .NET were second- and third-worst behind Java, with the industry average settling at $3.61. ABAP did the best with a score near zero.

Bad code plagues business applications, especially Java ones

DECEMBER 9TH, 2011

A new study examining 365 million lines of code in 745 applications identifies bad coding practices that affect security, performance and uptime, with Java

Enterprise Edition applications having the

greatest number of problems. Cast

Software, which makes tools that automate the analysis of business

applications, examined programs written in Java-EE, .NET, ABAP, C, C++, Cobol, Oracle Forms, and Visual Basic, used across a wide range of industries from energy and financial services to IT

consulting, insurance, government, retail, telecom, and more.

(10)

Current status on application

security

• Most security vulnerabilities are caused by errors in

applications.

- Gartner: > 70% - NIST: 92%

• Conclusion

– Applications are not inherently secure

(11)

Impact of adding security at the

end

• Cost increases exponentially with each phase

• Effectiveness decreases

• Longer time to market

• Revenue loss

• Recommendation:

– Security should be an integral part of the software development process and not an afterthought that is added at the end of the project.

Time

Cost D C

T

D

(12)

Software Development Process

• Requirements

• Design

• Coding

• Test

• Deployment

• Beneficial for all software development methodologies,

such as iterative, agile and waterfall models.

(13)

Software Development Process

• Adding security activities to the development process

Requirements Design Code Test Deployment

2. Security requirements 1. Risk analysis 8. Risk-based security tests 7. Security

unit testing 10. Penetra-

tion testing 5. Design review 6. Code review and analysis 3. Threat modeling Iterative approach 9. Hardening And patching 4. Security architecture

(14)

OWASP Software Assurance

Maturity Model

• Maturity model will help to:

– Evaluate an organization’s existing software security practices – Build a balanced software security program

– Demonstrate concrete improvements to security assurance program – Define and measure security-related activities within an

organization

(15)

Software Development Process

Requirements

Risk Analysis Security requirements

• Design

• Coding

• Test

• Deployment

(16)

DOING SECURITY RIGHT FROM THE START!

Activity 1: Risk Analysis

• Analysis and measurement

– How much money/resources can be spent on security?

– Which system components or other aspects should be targeted first?

– How much improvement is gained by security expenditures

• Risk analysis methods

– Quantitative: ALE=SLE ($) * ARO – Qualitative: High, Medium, Low

• Define

– Business goals

(17)

Activity 2: Security requirements

• Define explicit security requirements and separate them

from functional requirements

– Generic requirements based on security policy

(18)

DOING SECURITY RIGHT FROM THE START!

Activity 2: Security requirements

• Generic security requirements based on security policy

Strategic

Tactical

Operational

High-level Policy: -Classification

-Risk management framework -Responsibilities

Specific measures for particular classifications.

Specific implementation guidelines

(19)

Online webshop Browse catalog Customer Operator Register customer Order goods Change password Logon <extend> <include> Online webshop Browse catalog Customer Operator Register customer Order goods Change password Logon Attacker Flood system <extend> <include> Steal card info Tap communica-tion Obtain <include> <include> <include> <include>

Activity 2: Security requirements

Online webshop Browse catalog Customer Operator Register customer Order goods Change password Logon Attacker Block repeated registrations Flood system <prevent> <extend> <include> Steal card info Tap communica-tion Obtain Encrypt communica-tion Monitor system Enforce password policy <extend> <extend> <include> <include> <include> <include> <include> <include> <include> <include> <prevent> <prevent> <detect> <detect>

• Capture specific requirements with use case

– Easily be mapped to Java EE roles and authorizations – For each function focus on

• Data security • Access control

• Transaction integrity • Separation of duties • Uptime

(20)

Requirements phase summary

• Maturity

– Make use of risk analysis to get priorities – Always start with a clear security policy

– Translate policy into explicit and measurable requirements – Use use cases to define roles and authorizations

– Use abuse cases to define product specific security requirements

(21)

Software Development Process

• Requirements

Design

Threat modeling Security Architecture Design review

• Coding

• Test

• Deployment

(22)

Activity 3: Threat modeling

• Refine the threats identified in the misuse case models

• Threat modeling is a security-based analysis that:

– Helps understand where the product is most vulnerable – Identifies and evaluates the threats to an application – Aims to reduce overall security risks

– Finds assets

– Uncovers vulnerabilities

– Helps form the basis of security design specifications

• Link identified technical risks to the defined business goals

and risks

(23)

Activity 3: Threat modeling

• Identify threats with

STRIDE

:

– Spoofing identity

– Tampering with data

– Repudiation

– Information disclosure

– Denial of service

– Elevation of privilege

• Use

DREAD

to rate threats

– Damage potential

– Reproducibility

– Exploitability

– Affected users

– Discoverability

• Other threat modeling techniques

– Attack trees – OCTAVE

(24)

Activity 3: Threat modeling

Step 1

• Decompose application

– Use DFD or UML deployment diagrams

– Distinguish (inter)actors, data store, processes and boundaries

DOING SECURITY RIGHT FROM THE START!

Customer

Developer

Application Server Database Server

<data> Web Pages

Web Application <data> Payroll data payroll request deploy updated files requested page payroll request Data center

(25)

Activity 3: Threat modeling

Step 2

• Determine the threats to the system

– Use STRIDE to categorize threats

– Use threat trees to determine how the threat can manifest itself (root cause analysis)

– Rank the threats by decreasing risk, e.g. using DREAD

Gain user’s password Snoop basic Authentication connection Compromise server user store Mal. software reads local user’s pw HTTP traffic is unprotected Attacker views traffic and Need access to server

(26)

Activity 3: Threat modeling

Step 3

• Choose how to respond to the threats

– Accept the threat – Mitigate the threat – Insure the threat

– Inform the user of the threat

(27)

Activity 3: Threat modeling

Tools

(28)

Activity 4: Security Architecture

• Define secure design principles

• Define a list of accepted software frameworks

– Open-source committee

– Easy to check in Java EE projects by the use of Maven

DOING SECURITY RIGHT FROM THE START!  Principle of least privilege

 Multiple layers of defense

 Fail safely

 Use of secure defaults

 Avoid security by obscurity

(29)

Activity 4: Security Architecture

• Define design guidelines for

– Authentication – Authorization – Encryption

– Auditing and logging – Exception handling

– Input validation and output encoding

• Define secure coding guidelines to prevent a.o.

– Cross-site scripting (XSS)

– SQL injection and other injection flaws – Cross-site request forgery (CSRF)

– Insecure Direct Object References – etc.

(30)

Activity 5: Design reviews

• Manually inspect the design (documentation)

– Verification of requirements and threat model in design

• Attack surface and interfaces

– Inspect how security mechanisms are implemented • Are Java EE standards being used?

• Authentication, authorization, input validation, output encoding, error handling, logging and encryption.

– Verification against secure design principles and guidelines • No tools available

– Use checklists

(31)

Design phase summary

• Maturity

– Start the design with a threat modeling to identify highest risks

• Not only identify threats, but also rate them

– Guide software design process with a Security Architecture. – Make sure the design is reviewed against principles and

(32)

DOING SECURITY RIGHT FROM THE START!

Software Development Process

• Requirements

• Design

Coding

Code review and analysis

Security unit testing

• Test

(33)

• Static code analysis

– Include in automated build – Tools: Fortify, CodeAssure,

FindBugs, PMD, Sonar

• Manual code reviews:

– CIA business requirements – Security Architecture

– OWASP Code review guide – Language specific checklists

• Focus on high risk functionality

– Access control modules

– External interfaces (file, database, web services, web) – Payments module

Activity 6: Code review and

analysis

(34)

DOING SECURITY RIGHT FROM THE START!

Activity 7: Security unit testing

• Testing the smallest unit of an application

– Similar to normal unit testing, but focus on unhappy flow – Testing all possible paths for security breaches

– Take threat model and misuse cases as input

– Strive to 100% code coverage in vulnerable components

• Type of vulnerabilities that can be tested

– Input validation – Special characters – Exception handling – Security components

• Tools

(35)

Activity 7: Security unit testing

• Example

public class AccountValidatorTest extends TestCase {

public void testIllegalCharactersInName() { account.setName(“’”);

validator.validate(account, e);

assertTrue(“’ did not cause errors.”, e.hasFieldErrors(“name”); account.setName(“;”);

validator.validate(account, e);

assertTrue(“; did not cause errors.”, e.hasFieldErrors(“name”); account.setName(“<”);

validator.validate(account, e);

assertTrue(“< did not cause errors.”, e.hasFieldErrors(“name”); account.setName(“>”);

validator.validate(account, e);

assertTrue(“< did not cause errors.”, e.hasFieldErrors(“name”); }

(36)

DOING SECURITY RIGHT FROM THE START!

Code phase summary

• Maturity

– Setup code reviews and static code analysis integrated in daily build – Make use of existing proven standards and libraries

• Java EE Container Security. • JAAS, JCE, JSSE

(37)

Software Development Process

• Requirements

• Design

• Coding

Test

Security testing

• Deployment

(38)

Activity 8: Security Testing

• Security Testing is not the same as functional testing

– Functional security testing – Adversarial security testing – Performance testing

• Develop security test cases based on

– Security requirements – Misuse case models – Threat models

• Automate security tests

– E.g. Sqlmap, BeEF, JMeter, Cactus, jWebUnit, WATIR

• Flaws feed into defect tracking and root cause analysis

(39)

• Example: Testing HTML injection with jWebUnit

public class HTMLInjectionTest extends WebTestCase {

public void testHTMLInjection() throws Exception { beginAt(“/index.html”);

assertLinkPresentWithText(“Enter the Store); clickLinkWithText(“Enter the Store);

assertFormPresent(“searchForm”);

setFormElement(“query”, “<a id=\”injection\”

href=\”http://www.google.com>Injection</a>”); submit();

// If link present, injection succeeded assertLinkNotPresent(“injection”); }

}

(40)

• Example: test XSS with WATIR def test_XSS_In_Search $ie.goto(‘http://localhost:8080/ispatula/shop/index.do’) $ie.text_field(:name, ‘query’).set( ‘<script>window.open (“http://localhost:8080/ispatula/help.html”) </script>’) $ie.form(:action, /Search.do/).submit assert_raises( Watir::Exception::NoMatchingWindowFound, “Search field is susceptible to XSS”) {

ie2 = Watir::IE.attach(:url,

“http://localhost:8080/ispatula/help.html”) }

end

Activity 8: Security Testing

(41)

Test phase summary

• Maturity

– Use security requirements and threat models to develop security testing strategy

– Automate attacks with scripts and low-level programming languages and integrate in the build process

(42)

DOING SECURITY RIGHT FROM THE START!

Software Development Process

• Requirements

• Design

• Coding

• Test

Deployment

Hardening and patching

(43)

 Change default username/password for administrative console.

 Run Application Server under special OS user account.

 Enable host name verification is to avoid MITM attacks.

 Configure user lockouts and login time limits to prevent attacks.

 Prevent Application Server from sending its name and version

 Don’t use demo certificates.

 Restrict the size and time limit of requests on external channels.

Activity 9: Hardening and

patching

• Besides infrastructure, also harden your application server

– Checklists are provided by major vendors – Run application with limited privileges

– Automate deployment and hardening process

– Patch based on discovered vulnerabilities (also check frameworks!)

(44)

Activity 10: Penetration testing

• Use to discover configuration and environment problems

– Can easily be fixed at the end

– Run periodically to test for new vulnerabilities to be managed

• Standards are the prerequisite to metrics

– OWASP – OSSTMM – OASIS WAS

– NIST, PCI, others

• Tools

– HP WebInspect, Rational AppScan, Nessus

(45)

Deployment phase summary

• Maturity

– Automate deployment and hardening of your application server. – Perform penetration tests periodically

(46)

DOING SECURITY RIGHT FROM THE START!

Conclusions

• Java EE security is not enough to secure your

applications

• Security should be an integral part of the software

development process

– Risk Analysis – Security requirements – Threat modeling – Security Architecture – Design reviews

– Code review and analysis – Security (unit) testing – Hardening and patching – Penetration testing

(47)

Build applications more like cars…

(48)

Questions

(49)

References

• Capturing Security Requirements through Misuse Cases –

Sindre and Opdahl

• jWebUnit – http://jwebunit.sourceforge.net

• WATIR – http://wtr.rubyforge.org

• Sqlmap – http://Sqlmap.sourceforge.net

• BeEF – http://beefproject.com

• OpenSAMM – http://www.opensamm.org

• OSSTMM – http://www.osstmm.org

• OWASP – http://www.owasp.org

References

Related documents

Type of governance innovation HIV/AIDS Ebola AMR General/Other Creation of new institutions and governance arrangements New institutions and partnerships : UNAIDS, GFATM, Unitaid PDPs

Due to the different nature of the SAOs, two differ- ent approaches are used, depending on whether the decoded object represents the source position (direct sound and early

Robert Campbell is a pediatric cardiologist at Children’s Healthcare of Atlanta Sibley Heart Center and a Professor of Pediatrics, Emory University School of Medicine, Division of

Zmiany po- wierzchni światła komórek drewna wczesnego, procentowej zawartości drewna późnego oraz szerokości przyrostów rocznych w korzeniach odsłoniętych na działanie

Following the good, thou (or the designated leader) shall ask the group what the role player might do better the next time. Thou (or the designated leader) shall make sure that no

However, in contrast to Southern Irish English (SIrE), what is distinctive in NIrE is the phonological substrate influence it received from Scots, which is a Celtic

The Council specifically asked BiH also to “ establish functioning institutions as provided for in the constitution; to formulate a foreign trade and customs policy for

The author presented a situation that service quality is a focused evaluation that reflects the customer’s perception of reliability, assurance, responsiveness,