Security Audit of BAHMNI EMR & HOSPITAL SERVICE Web Application Level-1 Report
Security Audit of BAHMNI EMR & HOSPITAL SERVICE Web Application Level-1 Report
Test URL:
https://103.210.45.155/
Level-1
Uttar Pradesh-201301
INDIA
E-mail:cyberq[at]cyberqindia[dot]com
Web Application Security Test Report
for BAHMNI EMR & HOSPITAL
SERVICE web application
Any other company or product names mentioned are used for identification
purposes only, and may be trademarks of the irrespective owners.
Presented by:
Table of Contents
1 Introduction ....................................................................................................... 7
Purpose ....................................................................................................................... 7
Scope ............................................................................................................................ 7
Methodology.............................................................................................................. 7
Tools Used .................................................................................................................. 8
Executive Summary ............................................................................................... 8
Authority ..................................................................................................................... 8
Auditor ......................................................................................................................... 8
2 Table of Findings .............................................................................................. 9
3 Application Security Observations based on OWASP Top10,
2017 for “BAHMNI EMR & HOSPITAL SERVICE”. ................................... 12
4 Vulnerabilities with Severity Rating “High” ...................................... 13
Finding No. 1 ................................................................................................................... 13
Finding No. 2 ................................................................................................................... 15
Finding No. 3 ................................................................................................................... 17
Finding No. 4 ................................................................................................................... 19
5 Vulnerabilities with Severity Rating “Medium” ................................. 20
Finding No. 5 ................................................................................................................... 20
Finding No. 6 ................................................................................................................... 21
Finding No. 7 ................................................................................................................... 22
Finding No. 8 ................................................................................................................... 23
Finding No. 9 ................................................................................................................... 24
Finding No. 10................................................................................................................. 25
6 Vulnerabilities with Severity Rating “Low” ........................................ 26
Finding No. 11................................................................................................................. 26
Finding No. 12................................................................................................................. 27
Finding No. 13................................................................................................................. 28
Finding No. 14................................................................................................................. 29
07th June 2022 Confidential 5 of 43
Web Application Security Test Report
for BAHMNI EMR & HOSPITAL
SERVICE web application
1 Introduction
Purpose
CyberQ was asked to conduct a Web Application Security Test on the application
provided by Health and Family Welfare Department Nagaland. Details were
provided to the extent mentioned in “Scope of Work”. The testing was carried out
from CyberQ Consulting Pvt. Ltd., A 14-15, 3rd Floor Sector 59, Noida
Uttar Pradesh - 201301. The objective of this testing was to ensure the
security of the network and web server from external threats through the web
application.
Scope
The audit was carried on the testing Application URL:
https://103.210.45.155/ . This was Level – 1 testing. The scope of the
project was limited to find out the vulnerable areas of the Web Application.
Exploiting the vulnerabilities was out of scope for the tests.
Methodology
The methodology applied in Web Application Security Testing is explained in the
diagram below:
Information Gathering: One of the first steps of this test is to identify the Web
application environment, including the scripting language and Web server
software in use, and the operating system of the target server. However, this
step is generally omitted if the testing is limited to just the web application and
not the host.
Test Application: While testing the application, we follow but are not limited to
the OWASP standards. The top 10 vulnerabilities are tested for static and
dynamic websites. Our testing is done manually as well as using tools. An
indicative list of tools is given in the section below.
After an exhaustive testing, the findings are compiled and classified according to
a Risk Level of High, Medium or Low depending on the harm they may cause to
the Web Application, server or to the network.
A Report is created highlighting the findings together with details for each
finding.
Tools Used
The following tools were used:
• Burp Suite
• SQLmap
• CyberQ Proprietary Checklists and Test Cases
Executive Summary
The significant issues are given in this section, the Executive summary. These list
the security flaws that are of major concern. Vulnerabilities have been given a
Severity rating of High, Medium or Low based on the risk they may pose. The
basis of giving the severity rating is as described below:
S. Severity
Basis of giving severity rating
No. Rating
1 High Severely impact the system
2 Medium Impact the system in a limited manner
3 Low No direct impact on the system
Suggested improvements which are not non-
4 Information
compliances but would help in further enhancements
Authority
The Web Application Security Test was conducted under the authority of
Miss. Manenkala Longkumer (ICT Consultant).
Auditor
Mr. Arjun Singh
2 Table of Findings
The following key findings support our assessment of the weaknesses associated
with the application.
1. Injection Safe
Description: This test is to check whether the cookie can be reused in another
computer during the login phase. The server maintains the user state between
any client and itself by exchanging the cookie for each request-response
between them. If this unique identifier is not removed from the state table of the
web application server when user tries to login the same account from another
computer then any request subsequent to the user login will be happily serviced
by the web application, (Session Hijacking).
Severity Level: High
Recommendation: 1. Add a new cookie that randomly changes for each login
attempt. Generate different session id before and after authentication. Also
every request after the successful authentication should be associated with an
extra auth cookie: It is possible to view the sensitive information by fetching the
page from the cache option of the browser. session identifier cookie which also
randomly changes and expires when user logs out from the application or closes
the browser. For example;
Screenshots:
Step#1: In the authenticated session, refresh the page and capture the request.
Now copy authenticated URL and cookie as shown below:
Step#2: Now open another browser, paste and hit the copied URL. Replace the
cookie with the authenticated one that we’ve copied from browser 1. And turn
the intercept off.
Step#3: As you can see, we are able to access the authenticated pages without
entering the credentials. Thus, Session Hijacking is possible in Application.
Finding No. 2
Description: The password between server and client is passed in clear text. It
is possible for a malicious user to sniff into the network and access the
application and password.
Severity Level: High
Recommendation: Salt hashing is not implemented at login, thus password
travels in clear text. So, it is recommended to implement the hashing
technique/algorithm used at login in the application. Password should be
encrypted every time while being transmitted over the network. The solution is
to implement:
a) Salted SHA-256 technique in authentication or login module and
b) SHA-256 hash technique in change password and reset password modules.
The pre-requisite to this is that the backend database stores a SHA-256 hash of
the password. (SHA-256 hash is a cryptographic technique in which the actual
value can never be recovered). Here is how the salted SHA-256 technique works:
When a client requests for the login page, the server generates a random
number, the salt, and sends it to the client along with the page. A JavaScript
code on the client computes the SHA-256 hash of the password entered by the
user. It then concatenates the salt to the hash and re-computes the SHA-256
hash. This result is then sent to the server. The server picks the hash of the
password from its database, concatenates the salt and computes the SHA-256
hash. If the user entered the correct password these two hashes should match.
The server compares the two and if they match, the user is authenticated.
Screenshots:
Finding No. 3
Description: There is no limit on number of incorrect password retries while
trying to login. Thus, Brute force attack is possible in the Application.
Severity Level: High
Recommendation: Users should be restricted to a defined number of login
attempts per unit of time. After that defined number of login attempt,
application should block that user account or CAPTCHA can be implemented at
login page. This way automated attempt to login can be checked and brute force
attacks can be prevented.
CAPTCHA should follow the following condition:
a) The combination of alphanumeric value.
b) Combination of Upper case and lower-case letters.
c) Case-Sensitive
d) Its length should be minimum 6 characters.
e) Should not be a third-party CAPTCHA:
f) Should be Random and not follow a pattern.
g) Example: Ab73jy, PT34h8, Hos3t3, nic23n etc.
Screenshots:
Step#1: Enter the credentials, click on login button and capture the request.
Right click on captured request and click on send to intruder button as shown
below:
Step#3: As you can see in below snapshot, the valid password has lowest
length value. Thus, Brute force attack is possible in the Application.
Finding No. 4
Description: It is possible to upload malicious (.exe) file in the application.
Severity Level: High
Recommendation: Following things should be implemented in file upload
module:
• Inspect the content of uploaded files, and enforce a white list of accepted,
non-executable content types. Additionally, enforce a blacklist of common
executable formats, to hinder hybrid file attacks.
• Enforce a white list of accepted, non-executable file extensions.
• If uploaded files are downloaded by users, supply an accurate non-generic
Content-type header, and also a Content-disposition header which
specifies that browsers should handle the file as an attachment.
• Enforce a size limit on uploaded files (max 8-10 MB); this can be
implemented both within application code and in the web server's
configuration.
• Reject attempts to upload archive formats such as ZIP.
• Multiple file extension like test.pdf.txt.php.jif.jpg should not be allowed for
upload.
Screenshots:
Case 1: upload the .pdf file which is converted from .exe extension to .jpg file.
Click on Add button and capture the request. As you can see malicious file is
travelling from client end to server end. As you can see, the file will be uploaded
successfully.
Finding No. 5
Screenshots:
Finding No. 6
Description: Banner grabbing (which may help attacker to learn more about his
target) is possible in the application.
Screenshot:
Step#1: As you can see that the server’s name and version is disclosed.
Finding No. 7
Description: There is no CAPTCHA implemented in public dynamic pages in the
application.
Severity Level: Medium
Recommendation: Users should be restricted to a defined number of logins
attempts per unit of time. After that defined number of login attempt,
application should block that user account or CAPTCHA can be implemented at
login page. Application should validate CAPTCHA at both client and server ends.
Both client and server-side validation are mandatory.
CAPTCHA should follow the following condition:
a) The combination of alphanumeric value.
b) Combination of Upper case and lower-case letters.
c) Case-Sensitive
d) Its length should be minimum 6 characters.
e) Should not be a third-party CAPTCHA:
f) Should be Random and not follow a pattern.
g) Example: Ab73jy, PT34h8, Hos3t3, nic23n etc.
Screenshots:
Finding No. 8
Description: Application is displaying the runtime error to the end user.
Screenshot:
Finding No. 9
Description: Security headers such as (X-Content-Type-Options, X-Frame-
Options, Strict-Transport-Security, X-XSS, and Content-Security-Policy) are
missing in Application.
Severity Level: Medium
Recommendation: Following HTTP response security headers must be
implemented:
Header Rationale
The majority of CSP functionality only
Content-Security-Policy
affects pages rendered as HTML.
To require connections over HTTPS and
HTTP Strict-Transport-Security
to protect against spoofed certificates.
To prevent browsers from performing
X-Content-Type-Options MIME sniffing, and inappropriately
interpreting responses as HTML.
To protect against drag-and-drop style
X-Frame-Options
clickjacking attacks.
X-XSS header protects against Cross-
X-XSS-Protection
Site Scripting attacks.
Screenshots:
Finding No. 10
Description: Cross-site Tracing (XST) is possible in the Application.
Severity Level: Medium
Recommendation: xc
Screenshots:
Step#1: As you can see that we are change the http method Get to TRACE and
the sent the request see the response.
Recommendation: Verify that the path attribute, just as the Domain attribute,
has not been set too loosely. Even if the Domain attribute has been configured
as tight as possible, if the path is set to the root directory "/" then it can be
vulnerable to less secure applications on the same server.
Screenshot:
Finding No. 12
Description: HTTP Methods (OPTIONS) are enabled in the application.
Severity Level: Low
Recommendation: HTTP methods should be disabled in the application which
may prevent the application from security breach. Only GET and POST method
should be enabled in the application.
Screenshots:
Case#1: OPTIONS Methods are enabled.
Finding No. 13
Screenshot:
Finding No. 14
Description: Application has the provision to remember all user names those
have logged in or try to log in. Autofill is not disabled on login. Other fields can
also display information, which can be misused by a malicious user.
Screenshot:
Finding No. 15
Screenshot:
Step 1: In this step we are using first password (adminADMIN11) then click on
submit button and as you can show the password has been changed.
Step 2: In this step we are changing the password for the second time and
using another password (adminADMIN12) then click on submit button and as
you can show the password has been changed.
Step 3: In this step we are changing the password for the third time and using
same password (adminADMIN!) then click on submit button and as you can
show the password has been changed. As you can see the below screenshot.
Finding No. 16
Screenshot:
Finding No. 17
Screenshot:
Step 1: As you can see that we are click on help link show as a below.
Step 2: As you can see that third party URL open same tab.
Finding No. 18
Screenshot:
Finding No. 19
Screenshot:
Step#1: As you can see that open the inspect the page and go to console and
write the command javascript:alert(document.cookie); and see as below the
HttpOnly flag is not set in the application.
7 Observations
1. The application does not maintain audit trail properly where all user activities
have to be logged. In-case a malicious user tries to attack the application;
the application will not be able to trace the attacker.
• Audits are to be generated at the time of resource access and by the same
routines accessing the resource
• Information to be logged including the following: IP of the originating client,
Date, Time, username if any in addition to other details to be logged in the
web server.
• These IP, date, time, session details, user details (NO password), referrer,
process id to be logged in application logs.
• To create audit logs use auto numbering so that every logged entry has a log
number, which is not editable. Then if one audit entry is deleted a gap in the
numbering sequence will appear.
• Log entries are to be hashed/signed so that changes to audit log can be
detected.
Annexure#1
It is recommended to use the strategy of “Accept only known data”. Further all
the allowed input/output data must be sanitized on the server side by replacing
scripts tags, sent as part of user input/output, with appropriate representations.
For example
“<” by <
“>” by >
“(“ by(
This would avoid scripts from being executed on the client side.
Client side input must also be checked for URL encoded data. URL encoding
sometimes referred to as percent encoding, is the accepted method of
representing characters within a URI that may need special syntax handling to
be correctly interpreted. This is achieved by encoding the character to be
interpreted with a sequence of three characters. This triplet sequence consists of
the percentage character “%” followed by the two hexadecimal digits
representing the octet code of the original character. For example, the US-ASCII
character set represents a space with octet code 32, or hexadecimal 20. Thus its
URL-encoded representation is %20.
Other common characters that can be used for malicious purposes and their URL
encoded representations are: -
# Character URL encoded
‘ %27
“ %22
; %3b
< %3c
= %3d
> %3e
) %29
( %28
All input validation checks should be completed after the data has been decoded
and validated as acceptable content (e.g. maximum and minimum lengths,
correct data type, does not contain any encoded data, textual data only contains
the characters a-z and A-Z etc.)
Input Validation:
a. Escape Quotes:
Replace all single quotes to two single quotes:
<%
functionrepQuotes(strWords)
repQuotes = replace(strWords, “’”, “””)
end function
%>
<%
functionrem_culp_char(strwords)
dimbadChars
dimnewChars
badStuff = array(“select”,”union”,”drop”,”;”, “—“, “insert”, “delete”,
“xp_”, “*”)
newChars = strWords
fori = 0 to uBound(badChars)
newChars = replace(newChars, badStuff(i),””)
next
rem_culp_char = newChars
end function
%>
For example:
Other Preventions:
The default system account for Oracle should never be used
If extended stored procedures are not used, or have unused triggers, stored
procedures, user-defined functions, etc, then remove them, or move them to an
isolated server. Most extremely damaging SQL injection attacks attempt to make
use of several extended stored procedures such as cmd-shell and grant login, so
by removing them, theoretically blocking the attack before it can occur.
Note: To execute stored procedures user or database should have necessary
privileges.
Isolate database server and web server. Both should reside on different
machines.
(HTTP is a stateless protocol wherein the web server responds to each client
request without remembering the previous requests made and cannot link a set
of requests. Being able to separate and recognize user actions to specific
sessions is critical to web security.)
Password Encryption
The Login Name and Password should be encrypted while being transmitted over
the network. Changing the application protocol from HTTP to HTTPS would
mitigate this problem. Using HTTPS would transmit all the traffic between user
and server in encrypted format
The solution is to implement the salted SHA 256 or latest hashing technique. The
pre-requisite to this is that the backend database stores a SHA 256 hash of the
password. (SHA256 hash is a cryptographic technique in which the actual value
can never be recovered).
When a client requests for the login page, the server generates a random
number, the salt, and sends it to the client along with the page. A JavaScript
code on the client computes the SHA256 hash of the password entered by the
user. It then concatenates the salt to the hash and re-computes the SHA256
hash. This result is then sent to the server. The server picks the hash of the
password from its database, concatenates the salt and computes the SHA256
hash. If the user entered the correct password these two hashes should match.
The server compares the two and if they match, the user is authenticated.
Audit Trail
An Audit trail should be incorporated in the application admin module, where all
user activities have to be logged. Following points should be considered:
1. Failure login attempts.
2. User ID of successful logins.
3. All events/actions triggered by authenticated users.
4. Software Errors/Failures.
5. IP of the originating client can also be logged.
6. Timestamp (Date, Time) must be logged against each log entry.
7. Each log entry in the log file should have a unique identity number.
8. No confidential information like password, credit card number should ever be
logged.
9. There should be a functionality of reporting the logged-in information from the
log file to the administrator. An additional option can be added to the admin
module to view this information.
10. After a stipulated timeframe, online logs can be removed and stored offline.
11. Periodic backups/restores are essential.
12. Only “Admin” user should access “Audit Trail” and “Action Trail”. All actions
in the application should be recorded in the “Action Trail”.
Note: The application critical actions like “Change Password”, “User Creation”,
“File Upload” and other critical actions should be recorded in “Action Trail” page.
Both successful and unsuccessful actions should be recorded.
Browser Cache
• The browser has a capability to temporarily store some of the pages browsed.
These cached files are stored in a folder, like the Temporary Internet Files folder
in the case of Internet Explorer. When we ask for these pages again, the
browser displays them from its cache. This is much faster than downloading the
page from the server.
• The response header sent from the server has some cache control directives
that can be set from the code. These directives control the caching of content on
the client browser. The directives to be set are cache-control: no-cache or
cache-control: no-store.
• The no-cache directive in a response indicates that the response must not be
used to serve a subsequent request i.e. the cache must not display a response
that has this directive set in the header but must let the server serve the
request. The no-cache directive can include some field names; in which case the
response can be shown from the cache except for the field names specified
which should be served from the server. The no-store directive applies to the
entire message and indicates that the cache must not store any part of the
response or any request that asked for it.
• These directives solve the problem of caching to some extent but not
completely, since no-cache and no-store are not supported by HTTP 1.0 caches.
Also, we have observed that non-html content types like pdf and Excel
spreadsheets get cached on the browser even when the above tags are set.