DemoPasswordManager v1.0
DemoPasswordManager v1.0
ABC Security
1 Rivercourt, #803,
Jersey City, NJ 07310
Contact: (347)-748-4505
Report Details 1
Executive Summary 3
Overview 3
Summary of Findings 4
Technical Findings 6
SQL Injection 6
Directory Indexing and Browsing 9
External Redirect 11
Cookie and Session Exploits 13
CSRF 16
Clickjacking 18
Weak Password Complexity, no password aging, password reuse and unencrypted passwords transmitted 20
Missing account lockout 22
Version Disclosure Apache/PHP 23
User Enumeration 25
Appendices 25
Impact Rating and Ease of Exploit classification details: 25
Port Scan Details: 26
REPORT DETAILS
1
Report Version
Title Version Reviewer Date
Consultant Details
Name: Rajesh Kumar
ABC Security
Company:
(347)-748-4504
Contact No:
rajeshkumar@nyu.edu
Email:
Copyright
Copyright © 2019 ABC Security. All rights reserved.
2
EXECUTIVE SUMMARY
Overview
ABC security was assigned the task of carrying out Web Application Security Assessment for DataDog. This report details
the scope of testing conducted all significant findings along with detailed remedial advice.
http://192.168.1.29:5000/login
The web application security assessment was carried out from 03/21/2019 -03/24/2019.
Out of Scope:
▪ Stress testing
Objective:
The purpose of the assessment was to identify and validate various potential security vulnerabilities in the web application
of DemoPasswordManager as defined in scope. Due care was taken not to impact any server availability as agreed upon.
The OWASP Testing Framework was followed as a reference framework that comprises techniques and tasks that are
appropriate at various phases of security testing. Various phases were as listed:
• Perform various scans and information gathering to identify areas of exposure to the internet.
• Perform variously targeted scans to detect various vulnerabilities and manual testing to validate the results.
• Identifying application, objective, core components, areas of risk.
• Inspection of source code to identify other possible vulnerabilities.
• Classify vulnerabilities according to risk and impact.
• Final validation of vulnerabilities along with recommendation strategies for improvement in security posture.
• Responsible disclosure with a confidential report.
The summary below provides a non-technical audience with a summary of the key findings and relates these backs to business
impacts. Section three of this report relates the technical findings where DemoPasswordManager may want to invest further
resources in order to improve the overall security posture of their systems. Section four of this report highlights Appendices
which narrate various rating classifications, other technical details and various tools used during engagement aiming at a
technical audience.
3
Summary of Findings
This section gives an overall summary of key finds during the course of the engagement. The summary is classified according
to vulnerability impact ratings in three categories High, Medium and Low based on overall impact and damage it may cause
to firm. The details of classification are as mentioned in Appendices. Corrective action should be taken immediately according
to classification and response required.
High 1
Medium 6
Low 3
4
The above pie chart shows a summary of findings according to ratings. We found one HIGH rated vulnerability and
significantly high number of MEDIUM rated vulnerabilities which need prioritized attention along with LOW vulnerabilities
which need immediate attention for securing overall security posture of the firm.
The application is not deployed in a consistent format related to best practice guidelines for internet facing web application
deployment. The application is vulnerable to various attacks related to Inadequate Input Validation.
Major attacks which could leverage this vulnerability identified were SQL Injection, Cross-Site Scripting and
OS Command Injection. These require immediate attention and should be mitigated with priority.
If web application fails to properly validate and sanitize input field attacker can specify various crafted queries to get
information out of database via SQL Injection. This could lead to exposure of sensitive data like password, usernames, bug
details which in turn can cause extensive damage and financial loses.
Server Misconfiguration is another issue identified. Due to this various directories, files and other sensitive information is
exposed. The server misconfiguration must me identified and remediated. Here we found various default pages, directories,
version of Apache-PHP or even source code in the folder. External redirection validation was done. These issues can lead to
serious exposure of information along with reputation damage.
Session handling mechanism contains various logical vulnerabilities and they do not offer an end-to-end session. They are
vulnerable to Session replay, Man in middle attacks. These issues in combination allow for an attacker to hijack users’ sessions
and gain unauthorized and unauthenticated access to the application and users’ data. Also, cookies are not set to HTTP only
and also could be reused in multiple sessions. These vulnerabilities lead to serious risk scenario when the attacker is motivated
to capture sessions or even attempt to implement malicious activities on behalf of the user.
Username enumeration needs attention. It is recommended to have generic messages instead of specific ones as an attacker
can gather information on user base and can also use this to brute force user accounts password. Also, various policies related
to password need immediate priority and should be set according to standard organization password length, complexity,
and entropy policies.
Various vulnerabilities identified indicate the need for improvement in quality checks and consistent methodology in Software
Development Lifecycle. To remediate risks associated with vulnerabilities re-engineering of application keeping security
principles in mind is required.
5
TECHNICAL FINDINGS
This section records the key technical findings from the assessment along with recommendations on issues identified.
SQL Injection
Attackers could inject arbitrary SQL statements that modified the execution of the statements. This vulnerability allows an
attacker to get read and write access to any and all of the data stored within the database. An attacker could steal, modify
or destroy any or all of the data using SQL injection.
Parameters: search=
Reproduction steps:
1) Open the affected URL in browser: http://192.168.1.29:5000/search
2) Search with given payload.
Impact analysis:
During static code analysis of search page it was identified that search parameter of URL in web application was vulnerable
to SQL injection attacks. As proper input validation was not in place, this parameter could easily be exploited by attacker
to supply custom crafted queries to database to extract important data like tables, users, passwords, bug description.
Such vulnerable SQL injection parameters could be leveraged for exfiltration of sensitive data like
all tables with help of SQL Injection tools like Sqlmap, sqlninja, and also blind sql injection.
6
Figure 2 List of all password created by all users of password manager
Recommendations:
• Implement data validation routines that contain a default deny policy and restrict character classes to known good
values.
7
• Single quotes should be escaped to prevent misinterpretation.
• Whitelist acceptable values.
• Re-engineer the application so that it implements the least privilege model, i.e. use different database users to
perform SELECT, UPDATE, INSERT etc. commands. In the event of an attacker injecting code into a vulnerable
statement, the privileges afforded would be minimized. This remediation step does not solve the SQL injection
vulnerability, but it may limit the potential damage.
• Re-code the application so that it uses parameterized stored procedures to prevent variables from being interpreted
as SQL commands.
References:
https://www.owasp.org/index.php/SQL_Injection
https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet
8
Directory Indexing and Browsing
Reproduction steps:
1) Open the affected URL in browser: / http://192.168.1.29:5000/passwords/
2) Change index 1 to any other password ID.
Impact analysis:
It was found that directory listing was enabled on affected target URL. Due to this functionality attacker can guess various
directories available and explore them to find crown jewels. Here we found complete source code backed up at
http://192.168.1.29:5000/passwords/1. An attacker can do source code analysis to understand application logic, find
flaws in code and later exploit them with utmost accuracy leaving the application vulnerable to attacks.
Directory Indexing should be terminated as it can lead to information disclosure.
Recommendations:
References:
http://cwe.mitre.org/data/definitions/548.html
https://www.owasp.org/index.php/OWASP_Periodic_Table_of_Vulnerabilities_-_Directory_Indexing
10
External Redirect
Payload: ?next=http://www.duckduckgo.com
Reproduction steps:
1) Open the affected URL in browser: http://192.168.1.29:5000/login?next=http://www.duckduckgo.com
Impact analysis:
As we can see attacker can exploit this vulnerability to send victims to a malicious site which they will think is legitimate site
redirected from a trusted site.
Response by 192.168.1.29
HTTP/1.0 302 FOUND
Content-Type: text/html; charset=utf-8
Content-Length: 257
Location: http://www.duckduckgo.com
Vary: Cookie
Set-Cookie: session=.eJwdj8GKwzAMRH-l-NyDHdmWnW_YPyilyJaUls22ECeHpfTfV-
xpmIdmGL3dTVcadxluvrzdaTdxPzIGLeLO7uu1LMKnx_M0jt4N67Guv-
76uZ4tuMm4u3nfDjH3YDc71KKNUi05dBCkEAGrGkxUO_SqAT02gAkyp9w01jR5MxkYmi-
MuZecosbO2jSINzKFjgQcs0rIgtkzVB9g4qZ2iZVKaF5ZqDS0yX1settf3_K0PRE8lVQmnoBijzE2q-
WCILEBkXQiL7Umyx1Dtv8nAiB8_gAdxVN6.D3nvoA.HGCtQrJZ-IqpEdObxWvjsPbS0nY; HttpOnly; Path=/
Server: Werkzeug/0.14.1 Python/3.6.5
Date: Mon, 25 Mar 2019 04:50:40 GMT
11
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a
href="http://www.duckduckgo.com">http://www.duckduckgo.com</a>. If not click the link.
Recommendations:
References:
http://projects.webappsec.org/URL-Redirector-Abuse
http://cwe.mitre.org/data/definitions/601.html
12
Cookie and Session Exploits
Reproduction steps:
1) Send a GET request to the web server, capture the traffic by any proxy tool like Burp.
2) Identify the cookie/session id value
3) Replay with different techniques to achieve session manipulation
13
Impact analysis:
During session manipulation, we did not find any session timeout attribute in the GET request, which brings up another
vulnerability of no session timeout. This can be further chained to achieve simultaneous sessions and cookie reuse. In the
session configuration, HSTS, secure, SameSite and Max-Age attributes are missing.
Recommendations:
Session IDs are attacked by guessing, capturing or setting the id. You can protect against this in your own applications by
…
• Securing the cookie to make stealing the ID harder
• Limiting the session to a specific host to make attacks more difficult
• Changing the ID when escalating privileges and throughout the session life.
• Set Cookie with industry standard recommendations to protect against reuse and manipulation.
References:
14
https://blog.teamtreehouse.com/how-to-create-bulletproof-sessions
https://stackoverflow.com/questions/964071/correct-way-to-manage-sessions-in-php
https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Session_Management_Cheat_Sheet.md
15
CSRF
Reproduction steps:
1) Save the Html source code as any test page and run it in browser.
2) To change any user’s password, change the csrf token in the source code.
Source code
<html>
<!-- CSRF PoC - generated by Burp Suite Professional -->
<body>
<script>history.pushState('', '', '/')</script>
<form action="http://192.168.1.29:5000/edit" method="POST">
<input type="hidden" name="csrf_token"
value="IjQzMGE4NTgyZDIzYTRjNDQ0YmZiZmQ4NzNlNGIzYWFlY2FhMGU5OTUi.D3n2hw.LEY2FTyfIAoWJ1c9h1V10k9t9
ns" />
<input type="hidden" name="new_password" value="R@j09esh" />
<input type="hidden" name="new_password1" value="R@j09esh" />
<input type="submit" value="Submit request" />
</form>
</body>
</html>
Impact analysis:
Here we have tricked administrator into changing password of another user.
Recommendation:
16
• The most common method to prevent Cross-Site Request Forgery (CSRF) attacks is to append CSRF tokens to each
request and associate them with the user’s session. Such tokens should at a minimum be unique per user session but
can also be unique per request. By including a challenge token with each request, the developer can ensure that
the request is valid and not coming from a source other than the user.
• CSRF attacks are only possible since Cookies are always sent with any requests that are sent to a particular origin,
which is related to that Cookie. Due to the nature of a CSRF attack, a flag can be set against a Cookie, turning it
into a same-site Cookie. A same-site Cookie is a Cookie which can only be sent if the request is being made from
the same origin that is related to the Cookie being sent. The Cookie and the page from where the request is being
made, are considered to have the same origin if the protocol, port (if applicable) and the host is the same for both.
References:
https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet
https://www.veracode.com/security/csrf
https://www.acunetix.com/websitesecurity/csrf-attacks/
17
Clickjacking
Payload:
<style>
iframe { /* iframe from the victim site */
width: 800px;
height: 500px;
position: absolute;
top:0; left:0px;
opacity: 0.5; /* in real opacity:0 */
z-index: 2;
}
</style>
<div>Click to get 1 month free subscription</div>
<button>Click here!</button>
Impact analysis:
Here is a POC with HTML and iframe where we managed to get the server page to be loaded in the sample HTML code,
this could be heavily exploited in tricking the user to get user activity details. In the source code above, we have redirected
the visitor to the DemoPasswordManager register page, which is loaded every time user visits our sample page.
18
Figure 4 Clickjacking demo with a login screen
Recommendation:
1. Send the content as an HTTP Header – the directive is ignored if specified in a META tag
2. Use X-Frame-Options on critical configuration pages or other pages that require an “authentic user click”
3. Don’t use “sameorigin” if you have any page on your domain which accepts an arbitrary URL to frame
References:
https://www.owasp.org/index.php/Clickjacking
https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet
https://blogs.msdn.microsoft.com/ieinternals/2010/03/30/combating-clickjacking-with-x-frame-options/
19
Weak Password Complexity, no password aging, password reuse and unencrypted passwords transmitted
Also, the application did not support a password aging policy, allowing users to keep the same password indefinitely. This
vulnerability greatly increases the chances of compromise of a user’s password through either unintentional disclosure by a
user or through other electronic compromise.
Passwords for users of the application are transmitted unencrypted to the server. An attacker can leverage SQL injection
vulnerability in order to extract user credentials and password values. An attacker could use the same vector to impersonate
authorized users and gain access to potentially sensitive information.
Impact analysis:
The application allows for the use of weak passwords; depending on the strength of the user's chosen password, brute force
guessing could take an unskilled attacker as little as a few seconds to guess.
Moreover, an attacker with access to a user's credentials would be able to indefinitely compromise an account as there
doesn’t exist any password aging policy.
An external attacker would need the ability to query the backend database, via an attack vector such as SQL Injection or
access to unencrypted database backup media. Here we managed to get user passwords and information from the database.
Recommendation:
1) Re-engineer the application to user's chosen password, brute force guessing could take an unskilled attacker as
little as a few seconds to guess. introduce functionality that allows the implementation of a minimum password
strength that can be set in line with corporate security policy and best practice.
20
2) The accounts should be routinely audited in order to prevent and detect the use of weak passwords. Passwords
should be set to expire on a regular basis and the application should maintain a history of at least the last 3
passwords to prevent password repetition.
3) Use a one-way cryptographic hash function to store passwords in the database rather than using plain text
4) Implement a password aging policy that requires users to change their passwords at least every 90 days.
5) Password reuse should not be allowed, it helps in protecting users in case of an attack and breach of passwords.
References:
https://www.resolver.com/trust/policies/corporate-password-policy/
https://www.sans.org/security-awareness-training/blog/time-password-expiration-die
https://stackoverflow.com/questions/1054022/best-way-to-store-password-in-database
21
Missing account lockout
Impact analysis:
Without an account lockout mechanism to restrict the number of authentication attempts, an attacker would have an unlimited
number of attempts to guess the configured password and unless their brute force attempt was discovered they would
eventually guess even a strong password.
Recommendation:
Implement an account lockout mechanism that restricts the number of login attempts. Industry best practice suggests a maximum
figure of failed login attempts to be between 3 and 5 attempts.
The account lockout should either be implemented as a random period of time i.e. between 1 and 5 minutes to defeat
automated brute force tools or should remain locked until unlocked by an administrator or through an account reset process
that can be initiated by a user the implementation of which is subject to security policy requirements. All unsuccessful login
attempts should be tracked in a database or other stateful component and should not be tracked in a session variable.
References:
https://www.owasp.org/index.php/Testing_for_Weak_lock_out_mechanism_(OTG-AUTHN-003)
22
Version Disclosure Apache/PHP
Impact analysis:
Information disclosure in banner grab reveals sensitive data, such as technical details of the web server, environment, or user-
specific data. Sensitive data may be used by an attacker to exploit the target web application, its hosting network, or its
users. This helps an attacker to launch target specific attacks.
The web server HTTP header responses displayed the type and version of software running on the server. Knowledge of the
specific web server version allows an attacker to quickly identify known vulnerabilities that may be present in that particular
server. This vulnerability constituted information leakage and did not directly impact the security posture of the server
however it is useful and time-saving to the attacker.
Recommendation:
• If possible, configure the server to provide false or no information. Remove all default content from
the system in order to reduce its known signature footprint.
• Edit your Apache configuration file and Add/Edit following variables. After making changes restart your Apache
service.
ServerTokens Prod
ServerSignature Off
• In order to prevent PHP from exposing the fact that it is installed on the server, by adding its signature to the web
server header we need to locate in php.ini the variable expose_php and turn it off. _ By default expose_php is
23
set to On. In your php.ini (based on your Linux distribution this can be found in various places, like /etc/php.ini,
/etc/php5/apache2/php.ini, etc.) locate the line containing “expose_php On”_and set it to Off:
References:
https://www.tecmint.com/hide-apache-web-server-version-information/
http://www.ducea.com/2006/06/16/apache-tips-tricks-hide-php-version-x-powered-by/
24
User Enumeration
Reproduction:
1) Open the following URL in browser: http://192.168.1.29:5000/login
2) Change the user name to any random value in the user field and click sign in.
3) Repeat the request by correct user name and incorrect password and observe the differences.
Impact analysis:
The malicious actor is looking for differences in the server's response based on the validity of submitted credentials. Here we
try to look out for a number of users in-app with various user ids. We can go on incrementing until we know an exact number
of users. Here we found there are 5 users as id=6 showed user not found.
Recommendation:
Send generic error messages instead of specific “Username is invalid”.
References:
https://www.gnucitizen.org/blog/username-enumeration-vulnerabilities/
https://www.owasp.org/index.php/Testing_for_User_Enumeration_and_Guessable_User_Account_(OWASP-AT-002)
APPENDICES
25
Vulnerability Impact Ratings:
Impact rating represents the rating of web application vulnerabilities that could lead to a serious impact on the firm.
Depending on environment and vulnerability in context, this rating is computed keeping in mind the financial, reputation,
availability and relationship impacts.
In usual case it is, Vulnerability impact rating= Base impact rating + Environmental impact rating.
Medium:
Medium rating is reserved for vulnerabilities which have a very moderate impact but could lead to a loss if exploited. This
rating must be interpreted as attention should be taken to mitigate the vulnerability.
Examples of such vulnerabilities are:
Application Errors.
External Redirects.
Session management.
CSRF
Low:
Low rating is reserved for vulnerabilities which have very low security impact but could lead to information disclosure or loss
if exploited. Usually, these vulnerabilities are chained with others to form complex attack cases.
Examples of such vulnerabilities are:
Information Disclosure
Directory Browsing
Enumeration errors.
Difficult:
This type of vulnerabilities requires advanced attacker skills and are very difficult to exploit or require special knowledge.
Moderate:
This type of vulnerabilities requires normal attacker skills and are moderately difficult to exploit. Usually, such moderate
exploitation techniques combine the use of information and specialized tool set.
Easy:
This type of vulnerabilities requires no attacker skills and could be exploited by anyone based on information obtained. Such
vulnerabilities are easily exploitable.
Port Service
22 SSH-OpenSSH 7.6p1
26
5000 Werkzeug httpd 0.141
27