datatheorem / datatheorem/TrustKit-Android

TrustKit throws IllegalArgumentException

Open
#52 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
604
Forks
90
Avg merge
1h 29m
Merged PRs (30d)
2

Description

Hello!

Describe the bug

I'm seeing one crash in Google play console:

java.lang.IllegalArgumentException: 
  at com.datatheorem.android.trustkit.config.TrustKitConfiguration.getPolicyForHostname (TrustKitConfiguration.java:90)
  at com.datatheorem.android.trustkit.pinning.TrustManagerBuilder.getTrustManager (TrustManagerBuilder.java:67)
  at com.datatheorem.android.trustkit.TrustKit.getTrustManager (TrustKit.java:390)

https://github.com/datatheorem/TrustKit-Android/blob/master/trustkit/src/main/java/com/datatheorem/android/trustkit/config/TrustKitConfiguration.java#L91

To Reproduce

Unfortunately I cannot reproduce it. It happens to just two users.
I just enabled certificate pinning for one default server (and user can use their own server for which pining is not enabled).
It looks like server url is not valid, but I validate server url with:

https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/HttpUrl.java#L903

before creating http client:

okhttp3.OkHttpClient.Builder httpClient = new okhttp3.OkHttpClient.Builder();
X509TrustManager[] trustManagers = { TrustKit.getInstance().getTrustManager(backendUrl) };

so I'm confused why TrustKit throws exception.

Expected behavior
App would not crash.

Or please, let me know how should I handle this exception?

TrustKit configuration

<domain-config cleartextTrafficPermitted="false">
	<domain includeSubdomains="true">*******.***</domain>
	<pin-set>
		<pin digest="SHA-256">********************************************</pin>
		<pin digest="SHA-256">********************************************</pin>
	</pin-set>
	<trustkit-config enforcePinning="true" disableDefaultReportUri="true">
	</trustkit-config>
</domain-config>

App details:

  • App target SDK: 28
  • App language: Java
  • Android version to reproduce the bug: 7.1 and 8

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with TrustKitConfiguration.java around line 90 and trace the call from TrustManagerBuilder.java:67 through TrustKit.java:390. Compare the value passed from backendUrl with the HttpUrl validation described in the report; the work is complete when the crash path has a defined non-crashing behavior or a clear handling recommendation.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.