Commit graph android_packages_modules_Co.../networksecurity
Message SHA1
Prevent duplicate downloads in DownloadHelper
This change modifies `DownloadHelper` to check if a URL is already
scheduled for download (in pending, running, or paused status) before
enqueuing a new request. If a download for the same URL is found, the
existing download ID is returned, avoiding redundant requests to the
`DownloadManager`.

Bug: 437217681
Test: atest NetworkSecurityUnitTests
Flag: EXEMPT BUGFIX
Change-Id: I64dd5473b4fdb23241f5e2503c65cb64db56617c

Sandro Montanari   commited 2025-08-29 01:02:47 -07:00
b7c4c84a37
Propagate system broadcast after log list install
Bug: 418685951
Test: atest CertificateTransparencyDownloaderTest
Flag: com.android.net.ct.flags.certificate_transparency_job
Change-Id: I5febd08057a2613b11bc79e62580266286d56808

Sandro Montanari   commited 2025-07-24 11:14:28 +00:00
b50b931030
Fix bug in CT demo app not showing failed connections
Bug: N/A
Test: m CertificateTransparencyDemoApp
Flag: TEST_ONLY
Change-Id: I3fb3846cee5e240b5c3df730455820206c63b8b0

Sandro Montanari   commited 2025-06-13 06:24:31 -07:00
f522d546a9
Add button to check for presence of log list in CT demo app
Bug: N/A
Test: m CertificateTransparencyDemoApp
Flag: TEST_ONLY
Change-Id: Icac546e2c291d105193d8457c58b14935a8bf6ae

Sandro Montanari   commited 2025-06-12 05:59:36 -07:00
4e50caac29
Remove v1 compatibility version
This version is deprecated, only download the latest version. Keep the
array in place to easily add the next version in the future.

Bug: 409884646
Test: atest NetworkSecurityUnitTests
Flag: EXEMPT bug fix
Change-Id: Ia367c0c796ba56a470edcbfa0bc93213c4829d3f

ThiĆ©baud Weksteen   commited 2025-05-14 13:18:27 +10:00
0978c3207e
Merge "Migrate CT demo app to Android" into main
Sandro Montanari   authored and   Android (Google) Code Review   commited 2025-04-29 05:07:55 -07:00
a7a37a8497
Migrate CT demo app to Android
Bug: 409238442
Test: m CertificateTransparencyDemoApp
Flag: NONE demo app for testing
Change-Id: I499989131a9ae8a37425caa420f6b9d4c415f7d0

Sandro Montanari   commited 2025-04-29 04:07:46 -07:00
e9524a5298
Replace log lists with same version and later timestamp
Fixes: 409236434
Test: atest NetworkSecurityUnitTests
Flag: com.android.net.ct.flags.certificate_transparency_service
Change-Id: I350211ee4886a8ba678fc64067cd134f8783e220

Sandro Montanari   commited 2025-04-24 02:57:41 -07:00
1ec8369341
Remove unused DataStore class
Bug: 407940468
Test: atest NetworkSecurityUnitTests
Flag: com.android.net.ct.flags.certificate_transparency_service
Change-Id: I8338087263c3f61bad061ac7687cd20d51685e67

Sandro Montanari   commited 2025-04-10 12:30:05 +00:00
9af93249bd
Remove the DataStore from the CT codebase
The DataStore is now unused and can be safely removed. See b/407940468
for more details on why this preferences file was removed.

Fixes: 407940468
Test: atest NetworkSecurityUnitTests
Flag: com.android.net.ct.flags.certificate_transparency_service
Change-Id: Ic4427958acef94984f728398bdb9a6f7e53a9cbe

Bessie Jiang   commited 2025-04-04 14:25:12 +00:00
706a61776d
Remove dependency on DataStore from CT logging infra
The ct.preferences file has caused some issues (e.g. b/404408218), and
now that the logic of the logging is on every log list update (as
opposed to a certain number of consecutive failures), there is limited
utility in still relying on the DataStore to maintain a number of
crashes as this can be aggregated on the server side anyways.

Bug: 407940468
Test: atest NetworkSecurityUnitTests
Flag: com.android.net.ct.flags.certificate_transparency_service
Change-Id: I63bd9d87e1abd74c112485e8debfa284b81cc1ad

Bessie Jiang   commited 2025-04-03 09:18:58 -07:00
20d4024748
Avoid storing download IDs in the ct.preferences file
We are trying to reduce the usage of the DataStore, as
it has caused the occasional headache in the past (see
for example ag/32804820).

This CL removes the storing download IDs on disk. Storing
the download IDs is unnecessary anyway, we schedule a new
download on a system_server or device reboot anyway.

Bug: 407940468
Test: atest NetworkSecurityUnitTests
Flag: com.android.net.ct.flags.certificate_transparency_service
Change-Id: I18bc752aa26978f877f669d343d5432f83a36ae4

Sandro Montanari   commited 2025-04-02 10:26:21 +00:00
0394ebba3b
Fix for b/404408218 that was not merged in time for the AOSP read-only migration.
Add validity checks on DataStore file

Add process to perform validity checks on DataStore to avoid
system_server crashes by corrupted DataStore file.

Flag: EXEMPT bugfix
Test: Manual
(cherry picked from https://android-review.googlesource.com/q/commit:e7deb2a847a87ed79747ab7a736a62072f79cde1)
Fix for b/404408218 that was not merged in time for the AOSP read-only migration.
(cherry picked from https://android-review.googlesource.com/q/commit:cbae03b06b1be8b877ac5ef13632969b9564b29d)
Merged-In: I13c6ccc8bb5c2c9b212273350374b22892c67adc
Change-Id: I13c6ccc8bb5c2c9b212273350374b22892c67adc

mtk80963   authored and   Sandro Montanari   commited 2025-03-31 07:25:11 -07:00
adf3bd7e02
Log when an IOException when reading the public key, content or metadata
file for CT signature verification

Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 378626065
Test: atest NetworkSecurityUnitTests
Change-Id: I2df5933f4cb39b82620f8bdd391ca800dfcf8ede

Bessie Jiang   commited 2025-03-28 10:11:33 +00:00
0bf58dac22
Merge "Add logging of when the public key has invalid encoding or is not on the allowlist" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-24 16:18:17 -07:00
8b8029d20a
Add logging of when the public key has invalid encoding or is not on the
allowlist

Flag: com.android.net.ct.flags.certificate_transparency_service
Fixes: 400704086
Test: atest NetworkSecurityUnitTests
Change-Id: I76669d184731d873a944bf77534bb73381cb7ef0

Bessie Jiang   commited 2025-03-24 13:53:20 +00:00
bf4402fe67
Merge "Add NetworkSecurityUnitTests to tethering-mainline-presubmit" into main
Sandro Montanari   authored and   Gerrit Code Review   commited 2025-03-18 02:49:34 -07:00
9a03538a23
Add CompatibilityVersion v2 to CT downloader
Bug: 377276991
Test: atest NetworkSecurityUnitTests
Change-Id: Ia8b7b7893b7edad6d108886eca12341703d3c8a0

Sandro Montanari   commited 2025-03-14 14:46:59 +00:00
af205e3b89
Add NetworkSecurityUnitTests to tethering-mainline-presubmit
Test with connectivity/tethering module only, to catch integration issues with older versions of other modules.

Only the unit test are added to the test_mapping for now. The CTS tests are not compatible with older dessert releases.

The min_sdk_version in the test build target should help preventing the
regressions from b/398885474.

Bug: 397130276
Test: on go/abtd
Change-Id: I215758a34901ff048a8279b4a417ef9f4797db0f

Sandro Montanari   commited 2025-03-11 12:05:53 +00:00
5a7eeec399
Add checks for CT public key against allowlist
This CL adds a check to make sure the public key downloaded by the CTDownloader
matches a known allowlist of keys. If the key does not appear in the allowlist,
we cannot make guarantee that the key has not been tampered with, so we will not
proceed with the downloads of the CT log list and its signature.

Bug: 374719543
Test: atest NetworkSecurityUnitTests
Change-Id: I185a2330d9a4d138c93522cd4b22920e8a2412a2

Sandro Montanari   commited 2025-03-05 11:16:10 +00:00
32c060fc81
Revert "Add mapping to trigger NetworkSecurity unit tests on presubmit for tethering-mainline-presubmit"
This reverts commit f37bf52f86.

Reason for revert: b/398885474

Change-Id: Ib5d6ee1fe2738518ba6c3de17c42bb59a673e6af

Sandro Montanari   authored and   Gerrit Code Review   commited 2025-02-25 02:45:00 -08:00
5a06ed3cb4
Add mapping to trigger NetworkSecurity unit tests on presubmit for tethering-mainline-presubmit
Test with connectivity/tethering module only, to catch integration issues with older versions of other modules.

Only the unit test are added to the test_mapping for now. The CTS tests are not compatible with older dessert releases.

Bug: 397130276
Test: n/a
Change-Id: I832bf21ebe5a0f7033e0f2a68714efa7a6e37bc8

Sandro Montanari   commited 2025-02-24 14:10:16 +00:00
f37bf52f86
Revert "Add mapping to trigger NetworkSecurity unit tests on presubmit for tethering-mainline-presubmit"
This reverts commit b54ea49050.

Reason for revert: Droidmonitor created revert due to b/397704210. Will be verifying through ABTD before submission.

Change-Id: I9ca21679c505c1db0ce40b607336dbf43abda011

Priyanka Advani (xWF)   authored and   Gerrit Code Review   commited 2025-02-19 12:28:14 -08:00
4a2854b30a
Add mapping to trigger NetworkSecurity unit tests on presubmit for tethering-mainline-presubmit
Test with connectivity/tethering module only, to catch integration issues with older versions of other modules.


Bug: 397130276
Change-Id: Idc2fec3fa7b17ae87f6dcebcf4179196abd9f971
Test: n/a

Sandro Montanari   commited 2025-02-19 03:03:14 -08:00
b54ea49050
Add catching of IllegalArgumentException, which gets thrown when there is a malformed Unicode escape character sequence
System crashes are occurring for partners (b/396308673) due to the DataStore failing to load. While we investigate the underlying cause, add IllegalArgumentExceptions to the catch clause to prevent the fatal exception from being thrown.

Change-Id: I99e72af60064e2f0a5eed69c4f82b6cc69ee5f66
Fixes: 396308673
Flag: com.android.net.ct.flags.certificate_transparency_service
Test: atest NetworkSecurityUnitTests

Bessie Jiang   commited 2025-02-13 09:14:29 -08:00
3f4ee6c4b5
Fix the string encoding issues with logging the signature
The signature should be logged _before_ decoded from the Base64
encoding in order to properly compare with what is published on gstatic.

Bug: 391327942
Bug: 378626065
Flag: com.android.net.ct.flags.certificate_transparency_service
Test: atest NetworkSecurityUnitTests
Change-Id: Ibde2d4f45b998f764e2cb8d0772a0536ff763a4a

Bessie Jiang   commited 2025-02-10 15:31:42 +00:00
20293a86ef
Add logging of the log list timestamp
This CL adds the parsed log list timestamp from the JSON log list, as
well as logging a SUCCESS event (with timestamp and signature) when the
log list has been successfully updated.

Fixes: 391327942
Fixes: 394278886
Bug: 378626065
Flag: com.android.net.ct.flags.certificate_transparency_service
Test: atest NetworkSecurityUnitTests

Change-Id: I8f0d96ca96cd89dce5da588cb478f9332537df48

Bessie Jiang   commited 2025-02-10 13:32:48 +00:00
ae659ace56
Modify CTLogger to take in the LogListUpdateStatus object instead of
individually passed parameters

This CL also moves the DataStore updates of the failure count into
CTLogger directly (CTDownloader will only modify the failure count on
complete success).

Note: due to limitations with Mockito (not being able to mock static
classes like the auto-generated CTStatsLog), there is no test class for
CTLoggerImpl.

Bug: 394278886
Bug: 378626065
Flag: com.android.net.ct.flags.certificate_transparency_service
Test: atest NetworkSecurityUnitTests
Change-Id: I4498bfe75e84c6ba1654cfa55912c46836f61e03

Bessie Jiang   commited 2025-02-05 18:47:01 +00:00
782fad0c3a
Merge "Fix bug in Killswitch implementation" into main
Sandro Montanari   authored and   Gerrit Code Review   commited 2025-02-05 05:05:08 -08:00
bc74f0050e
Add logging of the log list signature
As previously discussed, we will be logging the signature to help with
on-path attacker detection. See go/ct-android-notes for summary of the past
discussions. SignatureVerifier has been modified to return a status
object to better capture the various potential signature verification
failure statuses.

The log list timestamp will be added in a later change as
this will require modifying CompatibilityVersion's logic.

Bug: 378626065
Bug: 391327942
Bug: 394278886
Flag: com.android.net.ct.flags.certificate_transparency_service
Test: atest NetworkSecurityUnitTests
Change-Id: I33d08b2d8c0260237bb3c5a66770fdf409adf8b1

Bessie Jiang   commited 2025-02-04 16:52:07 +00:00
a0c6b166a1
Create an intermediate enum to represent the log list update status
All of the auto-generated enum naming in CTStatsLog is over 100+ chars
long, causing there to be numerous lint errors. This CL creates an
intermediate enum to make it easier to reference these status enums
without introducing lint warning fatigue.

Bug: 378626065
Flag: com.android.net.ct.flags.certificate_transparency_service
Test: atest NetworkSecurityUnitTests
Change-Id: I451a006961ee5d801b3fbf702d3f5282d0b02242

Bessie Jiang   commited 2025-02-03 19:39:14 +00:00
eb7de53d01
Fix bug in Killswitch implementation
The current implementation does not delete the CompatibilityVersion
directory if the killswitch is activated while the device is powered
off.

This CL fixes the bug and centralizes the handling of the killswitch
inside the CertificateTransparencyJob class, instead of spreading it
among multiple classes. Hopefully this change makes the killswitch
logic easier to follow and less-prone to mistakes.

Bug: 384688420
Test: adb shell device_config put network_security CertificateTransparencyLogList__service_enabled true/false
Flag: com.android.net.ct.flags.certificate_transparency_service
Change-Id: Ic1d0d78879753abc42829be18ce15f32a86532c5

Sandro Montanari   commited 2025-01-28 09:51:12 +00:00
0410737b6a
Rename the CTLogger APIs to reflect the atom name change
The atom no longer just represents log list update failures, and will
instead be representing the entire log list update result regardless of
success or failure.

Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 378626065
Test: atest NetworkSecurityUnitTests
Change-Id: Ide254542aeb9c9657e79a154e53f651478bb1a54

Bessie Jiang   commited 2025-01-24 15:40:51 +00:00
c9cefdbe1c
Remove the threshold logic for logging log list update failures
Previously, we would only log to statsd if a default threshold of 10 had
been met to avoid noise in the logs. Because we will instead be logging
every time a log list update happens (success or failure), we are
removing this threshold logic.

Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 378626065
Test: atest NetworkSecurityUnitTests
Change-Id: Id3ad2c75fcceb3c15add70d4263f6c443f145348

Bessie Jiang   commited 2025-01-24 12:18:48 +00:00
e48e790e32
Merge "Update CT log list update logging to reflect atom changes" into main
Bessie Jiang   authored and   Gerrit Code Review   commited 2025-01-23 09:37:57 -08:00
46ac499e60
Update CT log list update logging to reflect atom changes
This CL updates all usages of the atom FKA CertificateTransparencyLogListUpdateFailed, as it's now been renamed to CertificateTransparencyLogListUpdateStatusChanged to include more generic status updates beyond failures.

Change-Id: I32ac454a46d0dd2e10d1ac6388d25c8d5d199f79
Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 378626065
Test: atest NetworkSecurityUnitTests

Bessie Jiang   commited 2025-01-22 11:46:14 -08:00
78b7f41a63
Add NetSecConfigCertificateTransparencySctNoLogListTestCases to
networksecurity TEST_MAPPING

Now that ag/31339357 has been merged, the "no log list present" test
cases can now be added to the NetworkSecurity presubmit.

Bug: 378424118
Bug: 378423774
Test: atest --test-mapping packages/modules/Connectivity/networksecurity
Change-Id: Id72bf93657ea7257e37a52a42294bcd90b56591c

Bessie Jiang   commited 2025-01-22 19:41:18 +00:00
f449f91537
Add support for Base64 encoded signature
To simplify debugging, we are planning to publish the log list signature
as a Base64 encoded string.

It might take a while for the changes to the signature publishing pipeline
to reach prod, and we do not know exactly when that will happen. To avoid
accidental crashes, I added a fallback path to the verifier code that
reverts to use the signature as raw (not Base64 encoded) bytes. I will
remove the fallback path once the signature publishing changes are
finalized.

Bug: 374719543
Test: atest NetworkSecurityUnitTests
Change-Id: Ia785b554b840940dc81b47ac9bc2121c0b410ab0

Sandro Montanari   commited 2025-01-21 17:37:35 +00:00
ed61bfc39d
Ensure directory permissions are granted for CT root and version directories
In aosp/3434620 the logic of the DirectoryUtils#makeDir method
was changed to use dir.mkdirs() instead of dir.mkdir(). This
resulted in an issue where the permissions were not properly
set for the CT root directory.

Also, add tests to presubmit set for networksecurity.

Bug: 377276991
Test: atest --test-mapping packages/modules/Connectivity/networksecurity
Change-Id: I8a41224bf425b4ec869dc1ee087e8efda4644423

Sandro Montanari   commited 2025-01-16 10:52:52 +00:00
5cc68e42f8
Add device_config flag to change the threshold for logging log list
update failures to statsd

This will allow it easier to debug the logging logic, without needing to
hit the default threshold of 10.

Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 378626065
Test: atest NetworkSecurityUnitTests && tested flag behavior manually
Change-Id: I10c652615e78a700bb84aabaa37ddc850e031e56

Bessie Jiang   commited 2025-01-13 15:30:33 +00:00
7e4361ee09
Simplify failure logging code by removed failureLogged boolean flag
Instead of the boolean flag tracking that we are logging only once, use
an int to store the failureReason instead.

Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 378626065
Test: atest NetworkSecurityUnitTests
Change-Id: Ifcdb599f39bb8e1ce9c8b4a8d27fb4500df23256

Bessie Jiang   commited 2025-01-10 16:24:16 +00:00
5d90324b09
Move DownloadManager.COLUMN_REASON conversion to failure reason into
CTLogger

This CL adds a new API that will convert the
DownloadManager.COLUMN_REASON into the relevant proto failure reason
enum value. The reason why it is a new API rather than reusing an
existing one is because the parameter type is the same (int), so a
separate API will keep it clearer when the DownloadManager value vs. proto enum value is directly used.

Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 378626065
Test: atest NetworkSecurityUnitTests
Change-Id: I9028ba8f2cb95ccc6d21b19c58e0d15a9405c3f7

Bessie Jiang   commited 2025-01-09 15:49:17 +00:00
b6347cb862
Remove CertificateTransparencyInstaller
The task of installing a new log list is now performed by the
CompatibilityVersion class.

Also, each CompatibilityVersion provides the URLs hosting the signature
and log list files. We do not store that information in the DataStore.

Change-Id: I36b585dc6984278de1ab3e6f3dc872e22f06ebea
Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 377276991
Test: atest NetworkSecurityUnitTests

Sandro Montanari   commited 2025-01-09 10:42:17 +00:00
a5b88db27d
Add UPDATE_CONFIG permission check when start CTJob
To prevent untrusted apps from abusing the CTDownloader.

Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 384869526
Test: atest NetworkSecurityUnitTests
Change-Id: I7c701af673309a1fb854d690c85bfbf0b834fdc3

Sandro Montanari   commited 2025-01-07 15:35:13 +00:00
6f7013968b
Reduce the visibility of logging to statsd to package-private
This change makes CTLogger into a public interface and reduces the
visibility of the actual implementation to package-private, as it was only made
public to allow for testing via mocking.

Flag: com.android.net.ct.flags.certificate_transparency_service
Bug: 378626065
Test: atest NetworkSecurityUnitTests
Change-Id: Ifeab50244219396ba3d3fc7f87b8d6e31ff726c9

Bessie Jiang   commited 2025-01-07 11:31:16 +00:00
2435f1a245
Merge "Implement killswitch mechanism for Android CT" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-12-27 10:15:04 -08:00
1df64f7cf6
Implement killswitch mechanism for Android CT
Enabling the killswitch will scheduele the CT job and initialize the downloader.

Disabling the killswitch will remove the scheduled job, unregister the downloader and delete the compatibility version directory.

Also, remove the CertificateTransparencyFlagsListener as it is deprecated.

Bug: 384688420
Change-Id: I23d2201e22f305284ac47f521258f856b8a9efc2
Flag: com.android.net.ct.flags.certificate_transparency_service
Test: atest NetworkSecurityUnitTests

Sandro Montanari   commited 2024-12-27 08:07:10 -08:00
f24643a42a
Add logging when signature is either not found or doesn't pass
verification

Note: InvalidKeyExceptions may be thrown for other reasons (e.g.
signature algorithm not matching), hence the addition of a new Exception
to specify when the public key is missing.

Flag: com.android.net.ct.flags.certificate_transparency_service
Fixes: 384931263
Bug: 378626065
Test: atest NetworkSecurityUnitTests
Change-Id: I67341b1e2d169cf634e45ca84eb24e3a1f6d887e

Bessie Jiang   commited 2024-12-27 12:50:14 +00:00
558445cc9a
Add logging of cause of failure when the log list fails to update
Bug: 378626065
Flag: com.android.net.ct.flags.certificate_transparency_service
Test: atest NetworkSecurityUnitTests
Change-Id: I4c11d7b09ae0f32fccbdf4085192a0f04cd2321e

Bessie Jiang   commited 2024-12-23 17:15:00 +00:00
a1082d8444
Add new APIs to DataStore to allow for int storage
The failure count for CTLogListUpdateFailed is an integer, not a long.
We need APIs in DataStore to handle this different data type, as
otherwise it will result in an unnecessary cast from long <-> int, which
is a lossy conversion.

Bug: 384473786
Test: atest NetworkSecurityUnitTests
Change-Id: I3b31fc9faef4ac0dec77bc5adb8235a155a4a3d1

Bessie Jiang   commited 2024-12-18 20:24:05 +00:00
8d0c2c0b5f