• No se han encontrado resultados

TRASLADO EN AMBULANCIA

Alfa Medical Flex

XI. TRASLADO EN AMBULANCIA

Summary

Stack traces are not vulnerabilities by themselves, but they often reveal information that is interesting to an attacker. Attackers attempt to generate these stack traces by tampering with the input to the web application with malformed HTTP requests and other input data.

If the application responds with stack traces that are not man- aged it could reveal information useful to attackers. This infor- mation could then be used in further attacks. Providing debug- ging information as a result of operations that generate errors is considered a bad practice due to multiple reasons. For example,

Handling errors in Global.asax

When an error occurs, the Application_Error sub is called. A de- veloper can write code for error handling/page redirection in this sub.

Handling errors in Page_Error sub

This is similar to application error.

Error hierarchy in ASP .net

Page_Error sub will be processed first, followed by global.asax Application_Error sub, and, finally, customErrors section in web. config file.

Information Gathering on web applications with server-side technology is quite difficult, but the information discovered can be useful for the correct execution of an attempted exploit (for example, SQL injection or Cross Site Scripting (XSS) attacks) and can reduce false positives.

How to test for ASP.net and IIS Error Handling

Fire up your browser and type a random page name

If the server returns

it means that IIS custom errors are not configured. Please note the .asp extension.

Also test for .net custom errors. Type a random page name with aspx extension in your browser

If the server returns

Private Sub Application_Error (ByVal sender As Object, ByVal e As System.EventArgs)

Handles MyBase.Error End Sub

Private Sub Page_Error (ByVal sender As Object, ByVal e As System.EventArgs)

Handles MyBase.Error End Sub

http:\\www.mywebserver.com\anyrandomname.asp

http:\\www.mywebserver.com\anyrandomname.aspx

Server Error in ‘/’ Application.

--- ---

The page cannot be found Internet Information Services

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name

ErrorDocument 404 “Customized Not Found error message” ErrorDocument 403 /myerrorpagefor403.html ErrorDocument 501 http://www.externaldomain.com/errorp- agefor501.html <error-page> <error-code>404</error-code> <location>/myerrorpagefor404.html</location> </error-page>

protocol ensures not only confidentiality, but also authentica- tion. Servers are authenticated using digital certificates and it is also possible to use client certificate for mutual authentication. Even if high grade ciphers are today supported and normally used, some misconfiguration in the server can be used to force the use of a weak cipher - or at worst no encryption - permitting to an attacker to gain access to the supposed secure communi- cation channel. Other misconfiguration can be used for a Denial of Service attack.

Common Issues

A vulnerability occurs if the HTTP protocol is used to transmit sensitive information [2] (e.g. credentials transmitted over HTTP [3]).

When the SSL/TLS service is present it is good but it increments the attack surface and the following vulnerabilities exist:

• SSL/TLS protocols, ciphers, keys and renegotiation must be

properly configured.

• Certificate validity must be ensured.

Other vulnerabilities linked to this are:

• Software exposed must be updated due to possibility of known

vulnerabilities [4].

• Usage of Secure flag for Session Cookies [5]. • Usage of HTTP Strict Transport Security (HSTS) [6].

• The presence of HTTP and HTTPS both, which can be used to

intercept traffic [7], [8].

• The presence of mixed HTTPS and HTTP content in the same

page, which can be used to Leak information.

Sensitive data transmitted in clear-text

The application should not transmit sensitive information via unencrypted channels. Typically it is possible to find basic au- thentication over HTTP, input password or session cookie sent via HTTP and, in general, other information considered by regu- lations, laws or organization policy.

Weak SSL/TLS Ciphers/Protocols/Keys

Historically, there have been limitations set in place by the U.S. government to allow cryptosystems to be exported only for key sizes of at most 40 bits, a key length which could be broken and would allow the decryption of communications. Since then cryp- tographic export regulations have been relaxed the maximum key size is 128 bits.

It is important to check the SSL configuration being used to avoid putting in place cryptographic support which could be easily de- feated. To reach this goal SSL-based services should not offer the possibility to choose weak cipher suite. A cipher suite is spec- ified by an encryption protocol (e.g. DES, RC4, AES), the encryp- tion key length (e.g. 40, 56, or 128 bits), and a hash algorithm (e.g. SHA, MD5) used for integrity checking.

Briefly, the key points for the cipher suite determination are the following:

[1] The client sends to the server a ClientHello message

it may contain information on internal workings of the applica- tion such as relative paths of the point where the application is installed or how objects are referenced internally.

How to Test Black Box testing

There are a variety of techniques that will cause exception mes- sages to be sent in an HTTP response. Note that in most cases this will be an HTML page, but exceptions can be sent as part of SOAP or REST responses too.

Some tests to try include:

• invalid input (such as input that is not consistent with application

logic.

• input that contains non alphanumeric characters or query syn

tax.

• empty inputs.

• inputs that are too long.

• access to internal pages without authentication. • bypassing application flow.

All the above tests could lead to application errors that may con- tain stack traces. It is recommended to use a fuzzer in addition to any manual testing.

Some tools, such as OWASP ZAP and Burp proxy will automati- cally detect these exceptions in the response stream as you are doing other penetration and testing work.

Gray Box Testing

Search the code for the calls that cause an exception to be ren- dered to a String or output stream. For example, in Java this might be code in a JSP that looks like:

In some cases, the stack trace will be specifically formatted into HTML, so be careful of accesses to stack trace elements. Search the configuration to verify error handling configuration and the use of default error pages. For example, in Java this con- figuration can be found in web.xml.

Tools

• ZAP Proxy - https://www.owasp.org/index.php/OWASP_Zed_ Attack_Proxy_Project

References

• [RFC2616] Hypertext Transfer Protocol - HTTP/1.1

Testing for Weak SSL/TLS Ciphers, Insufficient

Transport Layer Protection (OTG-CRYPST-001)

Summary

Sensitive data must be protected when it is transmitted through the network. Such data can include user credentials and credit cards. As a rule of thumb, if data must be protected when it is stored, it must be protected also during transmission.

HTTP is a clear-text protocol and it is normally secured via an SSL/TLS tunnel, resulting in HTTPS traffic [1]. The use of this

can be customized and expanded at will). During the initial negotiations with an HTTPS server, if the server certificate relates to a CA unknown to the browser, a warning is usually raised. This happens most often because a web application relies on a certificate signed by a self-established CA. Whether this is to be considered a concern depends on several factors. For example, this may be fine for an Intranet environment (think of corporate web email being provided via HTTPS; here, obviously all users recognize the internal CA as a trusted CA). When a service is provided to the general public via the Internet, however (i.e. when it is important to positively verify the identity of the server we are talking to), it is usually imperative to rely on a trusted CA, one which is recognized by all the user base (and here we stop with our considerations; we won’t delve deeper in the implications of the trust model being used by digital certificates).

• Certificates have an associated period of validity, therefore

they may expire. Again, we are warned by the browser about this. A public service needs a temporally valid certificate; otherwise, it means we are talking with a server whose certificate was issued by someone we trust, but has expired without being renewed.

• What if the name on the certificate and the name of the server

do not match? If this happens, it might sound suspicious. For a number of reasons, this is not so rare to see. A system may host a number of name-based virtual hosts, which share the same IP address and are identified by means of the HTTP 1.1 Host: header information. In this case, since the SSL handshake checks the server certificate before the HTTP request is processed, it is not possible to assign different certificates to each virtual server. Therefore, if the name of the site and the name reported in the certificate do not match, we have a condition which is typically signaled by the browser. To avoid this, IP-based virtual servers must be used. [33] and [34] describe techniques to deal with this problem and allow name-based virtual hosts to be correctly referenced.

Other vulnerabilities

The presence of a new service, listening in a separate tcp port may introduce vulnerabilities such as infrastructure vulnerabilities if the software is not up to date [4]. Furthermore, for the correct protection of data during transmission the Session Cookie must use the Secure flag [5] and some directives should be sent to the browser to accept only secure traffic (e.g. HSTS [6], CSP).

Also there are some attacks that can be used to intercept traffic if the web server exposes the application on both HTTP and HTTPS [6], [7] or in case of mixed HTTP and HTTPS resources in the same page.

How to Test

Testing for sensitive data transmitted in clear-text

Various types of information which must be protected can be also transmitted in clear text. It is possible to check if this information is transmitted over HTTP instead of HTTPS. Please refer to specif- ic tests for full details, for credentials [3] and other kind of data [2].

Example 1. Basic Authentication over HTTP

A typical example is the usage of Basic Authentication over HTTP because with Basic Authentication, after log in, credentials are encoded - and not encrypted - into HTTP Headers.

specifying, among other information, the protocol and the cipher suites that it is able to handle. Note that a client is usually a web browser (most popular SSL client nowadays), but not necessarily, since it can be any SSL-enabled application; the same holds for the server, which needs not to be a web server, though this is the most common case [9].

[2] The server responds with a ServerHello message, containing

the chosen protocol and cipher suite that will be used for that session (in general the server selects the strongest protocol and cipher suite supported by both the client and server). It is possible (for example, by means of configuration directives) to specify which cipher suites the server will honor. In this way you may control whether or not conversations with clients will support 40-bit encryption only.

[1] The server sends its Certificate message and, if client

authentication is required, also sends a CertificateRequest message to the client.

[2] The server sends a ServerHelloDone message and waits for

a client response.

[3] Upon receipt of the ServerHelloDone message, the client

verifies the validity of the server’s digital certificate.

SSL certificate validity – client and server

When accessing a web application via the HTTPS protocol, a se- cure channel is established between the client and the server. The identity of one (the server) or both parties (client and server) is then established by means of digital certificates. So, once the cipher suite is determined, the “SSL Handshake” continues with the exchange of the certificates:

[1] The server sends its Certificate message and, if client

authentication is required, also sends a CertificateRequest message to the client.

[2] The server sends a ServerHelloDone message and waits for

a client response.

[3] Upon receipt of the ServerHelloDone message, the client

verifies the validity of the server’s digital certificate.

In order for the communication to be set up, a number of checks on the certificates must be passed. While discussing SSL and certificate based authentication is beyond the scope of this guide, this section will focus on the main criteria involved in as- certaining certificate validity:

• Checking if the Certificate Authority (CA) is a known one

(meaning one considered trusted);

• Checking that the certificate is currently valid;

• Checking that the name of the site and the name reported in

the certificate match.

Let’s examine each check more in detail.

• Each browser comes with a pre-loaded list of trusted CAs,

algorithms. Common interpretation, partially based on previous versions of the standard, is that at least 128 bit key cipher, no export strength algorithms and no SSLv2 should be used [19].

• Qualys SSL Labs Server Rating Guide [14], Depoloyment best

practice [10] and SSL Threat Model [20] has been proposed to standardize SSL server assessment and configuration. But is less updated than the SSL Server tool [21].

• OWASP has a lot of resources about SSL/TLS Security [22],

[23], [24], [25]. [26].

Some tools and scanners both free (e.g. SSLAudit [28] or SSLScan [29]) and commercial (e.g. Tenable Nessus [27]), can be used to as- sess SSL/TLS vulnerabilities. But due to evolution of these vulner- abilities a good way to test is to check them manually with openssl [30] or use the tool’s output as an input for manual evaluation using the references.

Sometimes the SSL/TLS enabled service is not directly accessible and the tester can access it only via a HTTP proxy using CONNECT method [36]. Most of the tools will try to connect to desired tcp port to start SSL/TLS handshake. This will not work since desired port is accessible only via HTTP proxy. The tester can easily circumvent this by using relaying software such as socat [37].

Example 2. SSL service recognition via nmap

The first step is to identify ports which have SSL/TLS wrapped ser- vices. Typically tcp ports with SSL for web and mail services are - but not limited to - 443 (https), 465 (ssmtp), 585 (imap4-ssl), 993 (imaps), 995 (ssl-pop).

In this example we search for SSL services using nmap with “-sV” option, used to identify services and it is also able to identify SSL services [31]. Other options are for this particular example and must be customized. Often in a Web Application Penetration Test scope is limited to port 80 and 443.

Testing for Weak SSL/TLS Ciphers/Protocols/Keys vulnerabil- ities

The large number of available cipher suites and quick progress in cryptanalysis makes testing an SSL server a non-trivial task. At the time of writing these criteria are widely recognized as minimum checklist:

• Weak ciphers must not be used (e.g. less than 128 bits [10]; no

NULL ciphers suite, due to no encryption used; no Anonymous Diffie-Hellmann, due to not provides authentication).

• Weak protocols must be disabled (e.g. SSLv2 must be disabled,

due to known weaknesses in protocol design [11]).

• Renegotiation must be properly configured (e.g. Insecure

Renegotiation must be disabled, due to MiTM attacks [12] and Client-initiated Renegotiation must be disabled, due to Denial of Service vulnerability [13]).

• No Export (EXP) level cipher suites, due to can be easly broken

[10].

• X.509 certificates key length must be strong (e.g. if RSA or DSA

is used the key must be at least 1024 bits).

• X.509 certificates must be signed only with secure hashing

algoritms (e.g. not signed using MD5 hash, due to known collision attacks on this hash).

• Keys must be generated with proper entropy (e.g, Weak Key

Generated with Debian) [14]. A more complete checklist includes:

• Secure Renegotiation should be enabled.

• MD5 should not be used, due to known collision attacks. [35] • RC4 should not be used, due to crypto-analytical attacks [15]. • Server should be protected from BEAST Attack [16].

• Server should be protected from CRIME attack, TLS compres

sion must be disabled [17].

• Server should support Forward Secrecy [18].

The following standards can be used as reference while assessing SSL servers:

• PCI-DSS v2.0 in point 4.1 requires compliant parties to use

“strong cryptography” without precisely defining key lengths and $ curl -kis http://example.com/restricted/

HTTP/1.1 401 Authorization Required Date: Fri, 01 Aug 2013 00:00:00 GMT

WWW-Authenticate: Basic realm=”Restricted Area” Accept-Ranges: bytes

Vary: Accept-Encoding Content-Length: 162 Content-Type: text/html

<html><head><title>401 Authorization Required</title></ head>

<body bgcolor=white>

<h1>401 Authorization Required</h1> Invalid login credentials!

</body></html>

$ nmap -sV --reason -PN -n --top-ports 100 www.example. com

Starting Nmap 6.25 ( http://nmap.org ) at 2013-01-01 00:00 CEST

Nmap scan report for www.example.com (127.0.0.1) Host is up, received user-set (0.20s latency). Not shown: 89 filtered ports

Reason: 89 no-responses

PORT STATE SERVICE REASON VERSION 21/tcp open ftp syn-ack Pure-FTPd

22/tcp open ssh syn-ack OpenSSH 5.3 (protocol 2.0) 25/tcp open smtp syn-ack Exim smtpd 4.80 26/tcp open smtp syn-ack Exim smtpd 4.80 80/tcp open http syn-ack

110/tcp open pop3 syn-ack Dovecot pop3d 143/tcp open imap syn-ack Dovecot imapd 443/tcp open ssl/http syn-ack Apache

465/tcp open ssl/smtp syn-ack Exim smtpd 4.80 993/tcp open ssl/imap syn-ack Dovecot imapd 995/tcp open ssl/pop3 syn-ack Dovecot pop3d Service Info: Hosts: example.com

Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .

Example 3. Checking for Certificate information, Weak Ciphers and SSLv2 via nmap

Nmap has two scripts for checking Certificate information, Weak Ciphers and SSLv2 [31].

$ nmap --script ssl-cert,ssl-enum-ciphers -p 443,465,993,995 www.example.com

Starting Nmap 6.25 ( http://nmap.org ) at 2013-01-01 00:00 CEST

Nmap scan report for www.example.com (127.0.0.1) Host is up (0.090s latency).

rDNS record for 127.0.0.1: www.example.com PORT STATE SERVICE

443/tcp open https

| ssl-cert: Subject: commonName=www.example.org | Issuer: commonName=*******

| Public Key type: rsa | Public Key bits: 1024

| Not valid before: 2010-01-23T00:00:00+00:00 | Not valid after: 2020-02-28T23:59:59+00:00 | MD5: ******* |_SHA-1: ******* | ssl-enum-ciphers: | SSLv3: | ciphers: | TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - strong | TLS_RSA_WITH_CAMELLIA_256_CBC_SHA - strong | TLS_RSA_WITH_RC4_128_SHA - strong | compressors: | NULL | TLSv1.0: | ciphers: | TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - strong | TLS_RSA_WITH_CAMELLIA_256_CBC_SHA - strong | TLS_RSA_WITH_RC4_128_SHA - strong | compressors: | NULL

|_ least strength: strong 465/tcp open smtps

| ssl-cert: Subject: commonName=*.exapmple.com | Issuer: commonName=*******

| Public Key type: rsa | Public Key bits: 2048

| Not valid before: 2010-01-23T00:00:00+00:00 | Not valid after: 2020-02-28T23:59:59+00:00 | MD5: ******* |_SHA-1: ******* | ssl-enum-ciphers: | SSLv3: | ciphers: | TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - strong | TLS_RSA_WITH_CAMELLIA_256_CBC_SHA - strong | TLS_RSA_WITH_RC4_128_SHA - strong | compressors: | NULL | TLSv1.0: | ciphers: | TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - strong | TLS_RSA_WITH_CAMELLIA_256_CBC_SHA - strong | TLS_RSA_WITH_RC4_128_SHA - strong | compressors: | NULL

|_ least strength: strong 993/tcp open imaps

| ssl-cert: Subject: commonName=*.exapmple.com | Issuer: commonName=*******

| Public Key type: rsa | Public Key bits: 2048

| Not valid before: 2010-01-23T00:00:00+00:00 | Not valid after: 2020-02-28T23:59:59+00:00 | MD5: ******* |_SHA-1: ******* | ssl-enum-ciphers: | SSLv3: | ciphers: | TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - strong

Documento similar