Penetration Test Report (7ASecurity): pentest report minivpn

Test Target:
minivpn OpenVPN Go Client
Pentest Report
Client:
Open Observatory of Network
Interference (OONI)
7ASecurity Test Team:
● Abraham Aranguren, MSc.
● Daniel Ortiz, BSc.
● Miroslav Štampar, PhD.
● Patrick Ventuzelo, MSc.
● Stefan Nicula, PhD.
7ASecurity
Protect Your Site & Apps From Attackers
sales@7asecurity.com
Pentest Report
INDEX
Introduction 2
Scope 4
Identified Vulnerabilities 5
MIV-01-002 Possible DoS via Integer Division by Zero (Medium) 5
MIV-01-003 Possible DoS via nil Pointer Dereference (Medium) 6
MIV-01-004 Possible DoS via Index Out of Range (Medium) 8
MIV-01-005 Possible DoS via Slice Bounds Out of Range (High) 10
MIV-01-006 Single Packet DoS via Spoofed UDP Handshake Response (Critical) 12
MIV-01-007 Possible DoS via Predictable Port Usage (Medium) 16
Hardening Recommendations 18
MIV-01-001 Possible DoS via index out of range (Low) 18
MIV-01-008 Possible File Disclosure via Error Messages (Info) 20
MIV-01-009 Possible Fingerprinting via Unique Traffic Patterns (Medium) 22
MIV-01-010 General Binary Hardening Recommendations (Info) 24
MIV-01-011 Missing Verification on VPN bootstrap-provider Utility Script (Info) 25
MIV-01-012 Possible MitM due to Missing TLS MinVersion (Medium) 26
Conclusion 28
7ASecurity © 2022
2
Pentest Report
Introduction
“A minimalistic OpenVPN implementation in Go”
From: https://github.com/ooni/minivpn
This document outlines the results of a whitebox security review conducted against the
minivpn implementation. The project was solicited by the Open Observatory of Network
Interference (OONI), funded by the Open Technology Fund (OTF), and executed by
7ASecurity in August 2022. The audit team dedicated 26 working days to complete this
assignment. Please note that this is the first penetration test for this project.
Consequently, identification of new security weaknesses was expected to be easier
during this assignment, as more vulnerabilities are identified and resolved after each
testing cycle.
During this iteration, the aim was to review the security posture of the open-source
minivpn tool. An innovative OpenVPN implementation in Go, that eliminates privilege
escalation attacks by design, as it runs with the permissions of a regular user. The goal
was to review the tool as thoroughly as possible, to ensure minivpn users can be
provided with the best possible security.
The methodology implemented was whitebox: The 7ASecurity team was supplied with
documentation, source code, as well as sample Windows, Mac OS and Linux binaries. A
team of 5 senior auditors executed all tasks required for this engagement, including
preparation, delivery, documentation of findings and communications.
The project entailed an audit of the minivpn OpenVPN Go client. The core goal in scope
for this exercise was to verify if the minivpn client delivers on its promise to protect user
data as well as network traffic, and suggest how the solution might be improved in the
future in order to become more difficult to attack by malicious adversaries. This included
testing the Go client, through static code analysis, as well as at runtime using fuzzing,
looking for VPN leaks, and other attack vectors, with a special focus on identifying
weaknesses that might put minivpn users or their data at risk.
All necessary arrangements were in place by August 2022, to facilitate a straightforward
commencement for 7ASecurity. In order to enable effective collaboration, information to
coordinate the test was relayed through email as well as a shared Slack channel. The
minivpn team was helpful and responsive throughout the audit, even during out-of-office
hours and weekends.
7ASecurity © 2022
3
Pentest Report
The project was competently defined and organized, which facilitated the audit for the
test team. As a result, the testers did not have the need to frequently ask or wait for
answers, and hence, there were no notable blockers during this iteration. Overall, the
test went well and 7ASecurity provided regular updates regarding the audit status and its
interim findings during this exercise.
The findings of the security audit can be summarized as follows:
Identified Vulnerabilities Hardening Recommendations Total
6 6 12
Moving forward, the scope section elaborates on the items under review, and the
findings section documents the identified vulnerabilities followed by hardening
recommendations with lower exploitation potential. Each finding includes a technical
description, a proof-of-concept (PoC) and/or steps to reproduce if required, plus
mitigation or fix advice for follow-up actions by the development team.
Finally, the report culminates with a conclusion providing detailed commentary, analysis,
and guidance relating to the context, preparation, and general impressions gained
throughout this test, as well as a summary of the perceived security posture of minivpn.
Scope
The following list outlines the items in scope for this project:
Whitebox Tests against minivpn OpenVPN Go client
● Target Version: https://github.com/ooni/minivpn/releases/tag/v0.0.5
● Linux, Windows and Mac OS X binaries were provided to 7ASecurity
● Access to a reference VPN server was provided to 7ASecurity
7ASecurity © 2022
4
Pentest Report
Identified Vulnerabilities
This area of the report enumerates findings that were deemed to exhibit greater risk
potential. Please note these are offered sequentially as they were uncovered, they are
not sorted by significance or impact. Each finding has a unique ID (i.e. MIV-01-001) for
ease of reference, and offers an estimated severity in brackets alongside the title.
MIV-01-002 Possible DoS via Integer Division by Zero (Medium)
Retest Notes: The MiniVPN team resolved this issue1 and 7ASecurity confirmed that the
fix is valid.
During the fuzzing process of the minivpn/vpn package, it was found that the
bytesPadPKCS7 function fails to perform a modulo operation when the blockSize
argument is zero. This led to the following crash error: “panic: runtime error: integer
divide by zero”. This issue affects projects using minivpn/vpn as a third-party library or
copying the vulnerable code into another project, if an attacker is able to control the
blockSize value. This issue was verified using the following Proof-of-Concept (PoC)
code:
PoC Code:
func Crash_bytesPadPCKS7() {
bytesPadPKCS7(nil, 0)
}
Output:
panic: runtime error: integer divide by zero
goroutine 1 [running]:
github.com/ooni/minivpn/vpn.bytesPadPKCS7({0x0?, 0xc0000021a0?, 0xc0000e3f70?},
0x406739?)
/home/user/go/src/github.com/ooni/minivpn/vpn/bytes.go:122 +0x253
github.com/ooni/minivpn/vpn.Crash_bytesPadPCKS7(...)
/home/user/go/src/github.com/ooni/minivpn/vpn/crash_reproduction.go:15
main.main()
/home/user/go/src/github.com/ooni/minivpn/vpn/reproduction/main.go:14 +0xab
exit status 2
The root cause for this crash can be found in the following code snippet:
1https://github.com/ooni/minivpn/pull/23
7ASecurity © 2022
5
Pentest Report
Affected File:
https://github.com/ooni/minivpn/blob/.../vpn/bytes.go#L122
Affected Code:
func bytesPadPKCS7(b []byte, blockSize int) ([]byte, error) {
// If lth mod blockSize == 0, then the input gets appended a whole block size
// See https://datatracker.ietf.org/doc/html/rfc5652#section-6.3
if blockSize > math.MaxUint8 {
// This padding method is well defined iff blockSize is less than 256.
return nil, errPaddingPKCS7
}
psiz := blockSize - len(b)%blockSize
padding := bytes.Repeat([]byte{byte(psiz)}, psiz)
return append(b, padding...), nil
}
In order to resolve this issue, the blockSize value should be checked and an error should
be returned if the value is zero.
MIV-01-003 Possible DoS via nil Pointer Dereference (Medium)
Retest Notes: The MiniVPN team resolved this issue2 and 7ASecurity confirmed that the
fix is valid.
During the fuzzing process of the minivpn/vpn package, it was found that the
EncryptAndEncodePayload function fails when dcs.dataCipher is null. This issue led to a
nil pointer dereference with the following crash error: “panic: runtime