0x01 Owasp Peru Oscar Martinez
0x01 Owasp Peru Oscar Martinez
0x01 Owasp Peru Oscar Martinez
[email protected]
fiery-owl.blogspot.com
@oscar_mrdc
La Realidad en Per?
Muchos con SQLi, XSS, credenciales dbiles, etc.
Mecanismos de Defensa
Requerimientos de seguridad en
Aplicaciones Web (OWASP ASVS)
Application Security Verification Standard
SQLi
Usar sentencias SQL precompiladas:
PreparedStatement pstmt = con.prepareStatement("update
empleado set sueldo = ? where id_empleado = ?");
pstmt.setDouble(1, 153833.00);
pstmt.setInt(2, 110592);
Spring
Jasypt
Java
Pattern
Commons
Validator
Cryptix
JCE
xml-enc
ACEGI
Struts
Write Custom
Code
Java URL
Encoder
Log4j
JAAS
Stinger
BouncyCastle
Reform
xml-dsig
Anti-XSS
HDIV
Many
More
Java Logging
Standard
Control
Implementacin de Controles
Implementacin de Controles
Validate:
getValidDate()
getValidCreditCard()
getValidSafeHTML()
getValidInput()
getValidNumber()
getValidFileName()
getValidRedirect()
Validation
Engine
safeReadLine()
User
Controller
Business
Functions
Data Layer
Backend
Presentation
Layer
Validate:
Validation
Engine
getValidDate()
getValidCreditCard()
getValidInput()
getValidNumber()
getValidInput
java.lang.String getValidInput(java.lang.String context,
java.lang.String input,
java.lang.String type,
int maxLength,
boolean allowNull)
throws ValidationException,
IntrusionException
Returns canonicalized and validated input as a String. Invalid input
will generate a descriptive ValidationException, and input that is
clearly an attack will generate a descriptive IntrusionException.
Parameters:
context - A descriptive name of the parameter that you are
validating (e.g., LoginPage_UsernameField). This value is used by
any logging or error handling that is done with respect to the value
passed in.
input - The actual user input data to validate.
type - The regular expression name that maps to the actual regular
expression from "ESAPI.properties".
maxLength - The maximum post-canonicalized String length
allowed.
allowNull - If allowNull is true then an input that is NULL or an
empty string will be legal. If allowNull is false then NULL or an
empty String will throw a ValidationException.
Returns:
The canonicalized user input.
Validator:
Para validar los datos de entrada ingresados por el usuario:
String validatedFirstName =
ESAPI.validator().getValidInput("FirstName",
myForm.getFirstName(), "FirstNameRegex", 255, false);
String cleanComment =
ESAPI.validator().getValidInput("comment",
request.getParameter("comment"), "CommentRegex", 300, false);
Decoding
Codecs:
Engine
Validation
CSS Codec
Engine
User
Controller
Business
Functions
Data Layer
Backend
Presentatio
nLayer
Encode:
Encode:
encodeForHTML()
encodeForHTMLAttribute(
)
encodeForJavaScript()
encodeForCSS()
encodeForURL()
Encoding
Encoding
Engine
Engine
encodeForSQL()
encodeForLDAP()
encodeForXML()
encodeForXPath()
encodeForOS()
encodeForHTML
java.lang.String encodeForHTML(java.lang.String input)
Encode data for use in HTML using HTML entity encoding
Note that the following characters: 00-08, 0B-0C, 0E-1F, and 7F-9F
cannot be used in HTML.
Parameters:
input - the text to encode for HTML
Returns:
input encoded for HTML
Encoder:
Para codificar los datos de salida:
String safeOutput =
ESAPI.encoder().encodeForHTML( cleanComment );
User
Controller
Business
Functions
Data Layer
Backend
Presentation
Layer
ESAPI
Quota
Exceeded
Authen
tication
Users
Loggin
g
Log Intrusion
Event
Intrusio
n
Detecti
on
Tailorable
Quotas
User
Controller
Business
Functions
Backend
Data Layer
PresentationLa
yer
Crypto:
Encryptor
encrypt() / decrypt()
hash()
seal() / unseal()
sign()
verifySeal()
verifySignature()
encrypt
CipherText encrypt(PlainText plaintext)
throws EncryptionException
Encrypts the provided plaintext bytes using the cipher
transformation specified by the property
Encryptor.CipherTransformation and the master encryption key as
specified by the property Encryptor.MasterKey as defined in the
ESAPI.properties file.
This method is preferred over encrypt(String) because it also
allows encrypting of general byte streams rather than simply
strings and also because it returns a CipherText object and thus
supports cipher modes that require an Initialization Vector (IV),
such as Cipher Block Chaining (CBC).
Parameters:
plaintext - The PlainText to be encrypted.
Returns:
the CipherText object from which the raw ciphertext, the IV, the
cipher transformation, and many other aspects about the
encryption detail may be extracted.