Ensure that all the retention policies attached to your Google Cloud log sink buckets are configured with the Bucket Lock feature. Enabling retention policies for your log buckets will protect the logging data stored within these buckets from being overwritten or accidentally deleted. As an additional layer of security, the Bucket Lock feature allows you to lock the data retention policy attached to your buckets in order to make sure that no one (including you) can shorten or cancel the retention policy duration.
By default, the Google Cloud Storage buckets used as log sink buckets do not have retention policies enabled and Bucket Lock configured. Enabling retention policies for your log buckets will guarantee you that all current and future objects in those buckets cannot be deleted or overwritten until they reach the age defined within the policies. Any attempts to delete or overwrite objects whose age is less than the retention period configured will fail and return a 403 (retentionPolicyNotMet) error. Locking your retention policies with Bucket Lock feature will prevent the policies from being reduced or removed. In this way, if your project becomes compromised by an attacker or a malicious insider who wants to cover his tracks, the logging data stored inside your log buckets is definitely preserved for forensics and security investigations.
Note: Locking a Google Cloud Storage bucket is an irreversible action. Once your log bucket is locked, you cannot remove the retention policy from the bucket or decrease the retention period set for the policy.
Audit
To determine if the retention policies configured for your log sink buckets are using the Bucket Lock feature, perform the following operations:
Remediation / Resolution
To configure locked retention policies for your GCP project logs sinks in order to prevent log data objects from being deleted or overwritten, perform the following operations:
References
- Google Cloud Platform (GCP) Documentation
- Routing and storage overview
- Route logs to supported destinations
- Retention policies and retention policy locks
- Use and lock retention policies
- gsutil tool
- retention - Provides utilities to interact with Retention Policy feature
- GCP Command Line Interface (CLI) Documentation
- gcloud projects list
- gcloud logging sinks list