Commit graph android_packages_modules_Co.../networksecurity
Message SHA1
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
Merge "Lazy initialize CertificateTransparencyDownloader and DataStore" into main
Sandro Montanari   authored and   Gerrit Code Review   commited 2024-12-18 06:10:50 -08:00
ff0ba88eed
Add a consecutive failure count to the CT DataStore
We plan on only logging failure metrics after 10
consecutive failures, so we need some way of storing it.

Fixes: 384473786
Test: atest NetworkSecurityUnitTests
Change-Id: Ib316309864c536893d08be2dc59b8a70965ebde6

Bessie Jiang   commited 2024-12-18 12:25:54 +00:00
6ae4c31703
Merge "Replace start job action with UPDATE_CT_LOGS system api" into main
Sandro Montanari   authored and   Gerrit Code Review   commited 2024-12-18 02:41:53 -08:00
8a6d83dfe0
Lazy initialize CertificateTransparencyDownloader and DataStore
To prevent Post Boot unlock regressions.

Flag: android.security.certificate_transparency_configuration
Bug: 383437444
Test: atest NetworkSecurityUnitTests
Change-Id: I9da001863998aba7cdf962275d8611e32e8efa84

Sandro Montanari   commited 2024-12-17 13:11:43 +00:00
ff3a006338
Replace start job action with UPDATE_CT_LOGS system api
Instead of defining our own action we can use the @SystemApi already
defined in ConfigUpdate.

Flag: android.security.Flags.certificate_transparency_configuration
Bug: 319829948
Test: atest NetworkSecurityUnitTests
Change-Id: Ibb3a534c0e0dca12a075d031983a8ee754261abd

Sandro Montanari   commited 2024-12-16 07:27:41 -08:00
e5daa72580
Revert aosp/3398620 as it causes a post boot unlock regression from loading the CT code & service.
Bug: 383437444
Change-Id: Ia87751ca2f66a0e3d750a219323fac3d4e69f2f6

Bessie Jiang   commited 2024-12-16 05:54:34 -08:00
952741b504
Gate CT via the certificateTransparencyConfiguration flag
Flag: android.security.Flags.certificateTransparencyConfiguration
Bug: 379988507
Test: atest NetworkSecurityUnitTests
Change-Id: Iffa024d427e120e10847ff03d1fd62f83c45ee3e

Sandro Montanari   commited 2024-12-12 14:48:54 +00:00
88564f625c
Change the default value of the flag to true as discussed via chat
Flag is already enabled on Trunkfood/Droidfood devices, and has soaked
for long enough to enable by default.

Bug: 379988507
Test: atest NetworkSecurityUnitTests
Change-Id: Ib0a9e3023ca46f5ce7a257af310789e1d25eb24d

Bessie Jiang   commited 2024-12-09 12:28:56 +00:00
b3492b7f76
Simplify the Android CT properties
Since we are moving away from runtime flags, the CT URLs for the log
list, signature, and public key will be hardcoded. I took the occasion
to simplify the logic for handling the Android CT properties and removed
the various "_PENDING" properties. They were making everything much
harder to follow.

Flag: com.android.net.ct.flags.certificate_transparency_job
Bug: 319829948
Test: NetworkSecurityUnitTests
Change-Id: I74bb946eccb5f376ee161ace2f151bf6ea1bdcff

Sandro Montanari   commited 2024-11-28 14:42:09 +00:00
9190aed0f8
Add SignatureVerifier class to handle public keys from different sources
The SignatureVerifier class allows setting a public key either as a
string or as a file. The former method is used when the key is read from
a flag via the CertificateTransparencyFlagsListener. The latter method
is used when the key is downloaded as a file by the daily
CertificateTransparencyJob.

This CL also adds an additional step to download a public key from a
URL via the CertificateTransparencyDownloader. Now the class goes
through the following steps:
1. Download a public key from the public key url,
2. If successful, download a log list signature from the metadata url,
3. If successful, download log list from the content url,
4. If successful, verifiy the log list using signature and public key,
5. If successufl, install the log list.

I also realized the CertificateTransparencyDownloaderTest was really
hard to understand, even for me that I wrote it xD
I attempted to clean up the test, hopefully it is a bit clearer now.
I'll probably make a second simplification pass in a follow-up CL.

Flag: com.android.net.ct.flags.certificate_transparency_job
Bug: 319829948
Test: NetworkSecurityUnitTests
Change-Id: I2be3e8b5895182d2afd8161aa44e54e1a6021685

Sandro Montanari   commited 2024-11-27 09:49:01 +00:00
3bd07a5ec6
Add daily CertificateTransparencyJob
Following a conversation with the Experiments team (b/374692404), it
appears we will not be able to use device config flags to trigger the
download of CT log lists.

This CL is the first of a series that will allow us to move away from
flags and instead rely on a daily job execution. For scheduling we rely
on the Android AlarmManager.

I previously attempted to schedule the daily job using the Android
JobScheduler. However, those attempts were unsuccessful beacause the
Tethering apex is not on the system_server classpath, so the system
would crash when attempting to load the class to execute the job.

Flag: com.android.net.ct.flags.certificate_transparency_job
Bug: 374692404
Test: NetworkSecurityUnitTests
Change-Id: I6ce44dcea464cab20d2df73b065e35c0f76dcbab

Sandro Montanari   commited 2024-11-21 14:54:50 +00:00
70c4de8edc
Make newly created CT directories executable
Directories treat the executable bit differently than files, and need it
to be set in order for the files within said directories to be
accessible. Without making the CT directories executable, the log list
file is not accessible. See
https://www.redhat.com/en/blog/linux-file-permissions-explained for more
details.

Test: atest NetworkSecurityUnitTests (also manually)
Bug: 319829948
Change-Id: I03c172e93dc3ecb50f69297ea47b2fdeb860048b

Bessie Jiang   commited 2024-11-13 16:17:26 +00:00
dfed8dc100
Log CT log list download failures
This CL adds a DownloadStatus class inside the DownloadHelper. The class
acts as a thin wrapper around the status and reason Ids returned by the
DownloadManager, with some utility methods to help with the
interpretation of the download status.

Bug: 319829948
Test: atest NetworkSecurityUnitTests
Change-Id: I111388ee37c09e30c02bb9bc9b3d65273961b91d

Sandro Montanari   commited 2024-11-12 11:13:02 +00:00
478ba513aa
Revert "Change the visibility of Config to be public, so it can be accessed from"
This reverts commit a618596be5.

Reason for revert: After discussing with tweek@, he pointed out that this may result in a slippery slope where the code may be tested in CTS instead of the device (https://screenshot.googleplex.com/BJZVK4FfXkWB2Rw).

Change-Id: Ic020cb98049c861947ac431c4b3761084e66073e

Bessie Jiang   authored and   Gerrit Code Review   commited 2024-11-05 11:42:26 +00:00
a4983fd628
Change the visibility of Config to be public, so it can be accessed from
the manual tests in the cts/ directory.

Flag: visibility change only
Test: visibility change only
Bug: 319829948
Change-Id: Ice7563e6f8742724a539e57f644b138f85eed349

Bessie Jiang   commited 2024-11-04 18:07:10 +00:00
a618596be5
Add compatibility version to log lists installed by CT
Introduce a CompatibilityVersion class to group installing operations on
log list related to the same compatibility version (e.g, v3).

Add support for multiple compatibility versions to the
CertificateTransparencyInstaller, although at the moment of writing
there exists only one compatibility version.

Test: atest NetworkSecurityUnitTests
Bug: 319829948
Change-Id: I503dd30cea93d2b1ba57e5ac91b8427394c453f8

Sandro Montanari   commited 2024-10-22 12:34:57 +00:00
a9aafb7c8c
Move public key to a DeviceConfig flag
Instead of hard-coding the public key value in code.

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

Sandro Montanari   commited 2024-10-10 12:46:44 +00:00
802c8f1a4d
Add Bessie to networksecurity OWNERS
Bug: n/a
Test: n/a
Flag: EXEMPT only changing OWNERS
Change-Id: Icc2639c7afadbbb6fa77c9354b20e974816ff5e7

Sandro Montanari   commited 2024-10-08 15:56:23 +00:00
6f73361204
Migrate CT namespace to "network_security"
Instead of the current "tehtering" namespace.

Also, flags pushed via DeviceConfig come with a
"CertificateTransparencyLogList" feature prefix.

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

Sandro Montanari   commited 2024-09-16 12:12:14 +00:00
5319f5c363
Merge "Make java_sdk_library dependencies explicit" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-10 19:12:45 +00:00
430a8ad33c
Make java_sdk_library dependencies explicit
modules should specify the submodule of java_sdk_library that the module
actually depends on

Test: CI
Bug: 358613520
Change-Id: I0367068c901df98483f6cf95160d3e7801881b0a

Jihoon Kang   commited 2024-09-10 00:01:31 +00:00
8401b6a9f0
Add CT log list data verification after download
The verification step assumes the metadata file, downloaded together with
the log list data, contains a signature generated using the public key
available at the certificate-transparency-community-site from Google
https://github.com/google/certificate-transparency-community-site/blob/master/docs/google/known-logs.md

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

Sandro Montanari   commited 2024-09-04 15:51:02 +00:00
2025a54069
Install CT log list on successful download
Add the CertificateTransparencyInstaller, that is in charge of
atomically update the log list file that is read by SCT verification in
Conscrypt.

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

Sandro Montanari   commited 2024-08-22 09:27:55 +00:00
32d814b205
Schedule log list download on flag update
Add the CertificateTransparencyDownloader to download the data and
metadata needed by Certificate Transparency.

The download is triggered when either the content URL, the metadata URL,
or the log list flags change.

The version numbers and URLs are stored in an on-disk DataStore to make
sure the same files are not downloaded on repeated flag updates.

Flag: com.android.ct.flags.certificate_transparency_service
Bug: 319829948
Test: atest NetworkSecurityUnitTests
Change-Id: Ic30e2973fdce99ea861d13f7777128161dd4003e

Sandro Montanari   commited 2024-08-21 10:18:00 +00:00
799860a21d
Add listeners for CertificateTranspaency DeviceConfig flags
Flag: com.android.ct.flags.certificate_transparency_service
Bug: 319829948
Test: adb shell device_config put certificate_transparency log_list_data_url <url>
Change-Id: Ief074fbef21ca18e6882852d53e90e7ddbbd78fa

Sandro Montanari   commited 2024-08-13 15:53:57 +00:00
1f4ddd0cf7
Add boilerplate code for CertificateTransparencyService
Flag: com.android.ct.flags.certificate_transparency_service
Bug: 319829948
Test: m
Change-Id: I69dd1b7346a013e9a990c9ae8cec1beb51be074d

Sandro Montanari   commited 2024-08-12 08:50:29 +00:00
9ffc0685d7