Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port mastg test 0020 (by @guardsquare) #3027

Merged
merged 6 commits into from
Nov 6, 2024

Conversation

titze
Copy link
Collaborator

@titze titze commented Nov 4, 2024

Thank you for submitting a Pull Request to the OWASP MASTG. Please make sure that:

  • Your contribution is written in the 2nd person (e.g. you)
  • Your contribution is written in an active present form for as much as possible.
  • You have made sure that the reference section is up to date (e.g. please add sources you have used, make sure that the references to MITRE/MASVS/etc. are up to date)
  • Your contribution has proper formatted markdown and/or code
  • Any references to website have been formatted as [TEXT](URL “NAME”)
  • You verified/tested the effectiveness of your contribution (e.g.: is the code really an effective remediation? Please verify it works!)

If your PR is related to an issue. Please end your PR test with the following line:
This PR closes #2961 .


## Overview

You can observe the TLS protocol the app uses by observing the traffic on the network.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to elaborate a bit on why "the TLS protocol the app uses by observing the traffic on the network" is a valuable (e.g. because of some limitation of doing it statically?)

@@ -0,0 +1,24 @@
---
title: Usage of Insecure TLS Protocols
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something more specific like "Usage of Insecure TLS Protocols in Network Traffic" or simply "Insecure TLS Protocols in Network Traffic"?

@@ -0,0 +1,34 @@
---
title: Usage of Insecure TLS Protocols
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something more specific like

  • "Use of Insecure TLS Protocols in Code"
  • "Insecure TLS Protocols Set in Code"
  • or "Insecure TLS Protocols Explicitly Allowed in Code"?

The "in Code" differentiates this test from the other one which is done at the network level.


## Evaluation

The evaluation fails if any ["insecure TLS version"](https://mas.owasp.org/MASTG/0x04f-Testing-Network-Communication/#recommended-tls-settings) is used.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always start the evaluation with "The test case fails"

Suggested change
The evaluation fails if any ["insecure TLS version"](https://mas.owasp.org/MASTG/0x04f-Testing-Network-Communication/#recommended-tls-settings) is used.
The test case fails if any ["insecure TLS version"](https://mas.owasp.org/MASTG/0x04f-Testing-Network-Communication/#recommended-tls-settings) is used.


## Overview

Multiple ways to enable insecure protocols exist in Android:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe better like this since these are not the only 2 ways of doing this on Android, right?

Suggested change
Multiple ways to enable insecure protocols exist in Android:
There are several ways to enable insecure versions of TLS in Android, including:


### Java Sockets

If the app uses Java Sockets, the API call `javax.net.ssl.SSLSocket.setEnabledProtocols(String[] protocols)` sets the enabled protocols.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better something like (please improve):

Java Sockets effectively bypasses the Android Network Security Configuration. Using the API call javax.net.ssl.SSLSocket.setEnabledProtocols(String[] protocols) allows the app to set insecure protocols.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left out the part of NSC here, since this is in the overview now and you cannot set the TLS version with it anyway.


## Evaluation

The evaluation fails if any ["insecure TLS version"](https://mas.owasp.org/MASTG/0x04f-Testing-Network-Communication/#recommended-tls-settings) is directly enabled, or if the app enabled `okhttp3.ConnectionSpec.COMPATIBLE_TLS`.s
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always start the evaluation with "The test case fails"

Please review the second edit. Maybe it's better to generalize this.

Suggested change
The evaluation fails if any ["insecure TLS version"](https://mas.owasp.org/MASTG/0x04f-Testing-Network-Communication/#recommended-tls-settings) is directly enabled, or if the app enabled `okhttp3.ConnectionSpec.COMPATIBLE_TLS`.s
The test case fails if any ["insecure TLS version"](https://mas.owasp.org/MASTG/0x04f-Testing-Network-Communication/#recommended-tls-settings) is directly enabled, or if the app enabled any settings allowing the use of outdated TLS versions, such as `okhttp3.ConnectionSpec.COMPATIBLE_TLS`.

tests-beta/android/MASVS-NETWORK/MASTG-TEST-0x20-1.md Outdated Show resolved Hide resolved

If the app uses Java Sockets, the API call `javax.net.ssl.SSLSocket.setEnabledProtocols(String[] protocols)` sets the enabled protocols.

### OkHttp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include this and use okhttp as an example?

### Third-party Libraries

Other libraries, such as [OkHttp](https://square.github.io/okhttp/), [Retrofit](https://square.github.io/retrofit/) or Apache HttpClient may have their own configurations for TLS protocols.

For example, if the app uses OkHttp and sets the allowed TLS protocols to `ConnectionSpec.COMPATIBLE_TLS` by calling `okhttp3.ConnectionSpec.Builder.connectionSpecs(...)`, this results in one or more insecure TLS versions (e.g, in TLS v1.1 (see ["configuration history"](https://square.github.io/okhttp/security/tls_configuration_history/#okhttp-313))).

The API call `okhttp3.ConnectionSpec.Builder.tlsVersions(...)` (["OkHttp documentation"](https://square.github.io/okhttp/features/https/)) can also be used to set the enabled protocols.

@titze titze requested a review from cpholguera November 5, 2024 18:15
tests-beta/android/MASVS-NETWORK/MASTG-TEST-0x20-1.md Outdated Show resolved Hide resolved
tests-beta/android/MASVS-NETWORK/MASTG-TEST-0x20-1.md Outdated Show resolved Hide resolved
tests-beta/android/MASVS-NETWORK/MASTG-TEST-0x20-2.md Outdated Show resolved Hide resolved
tests-beta/android/MASVS-NETWORK/MASTG-TEST-0x20-1.md Outdated Show resolved Hide resolved
tests-beta/android/MASVS-NETWORK/MASTG-TEST-0x20-1.md Outdated Show resolved Hide resolved
@cpholguera cpholguera merged commit 28d5e3c into OWASP:master Nov 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MASTG v1->v2 MASTG-TEST-0020: Testing the TLS Settings (android)
2 participants