Malicious access to an OSS bucket can cause bursts of high bandwidth and heavy traffic that generate unnecessary outbound traffic. In severe cases, the bucket is moved into a sandbox and the service becomes unavailable. Restrict who can access the bucket, or route access to the bucket through a security service, to stop the traffic at its entry point.
Choose a mitigation method
Choose one of the following three methods based on whether the bucket must remain publicly accessible and which security service you can use:
Method 1: Set the bucket ACL to private (Recommended) — Use this method when the objects in the bucket do not need to be accessed anonymously over the Internet. No additional service is required.
Method 2: Connect the bucket to WAF — Use this method when the bucket must remain accessible over the Internet through a custom domain name. This method requires a custom domain name that is bound to the bucket in the OSS console and a Web Application Firewall (WAF) 3.0 instance whose edition supports the Rate Limiting protection type. This protection type is supported only by the subscription Enterprise and Ultimate editions and the pay-as-you-go edition. For details, see WAF edition.
Method 3: Add your site to ESA — Use this method when your site is served through Edge Security Acceleration (ESA) and you need rate limiting at the network edge. This method requires an ESA Enterprise plan, which the network-wide rate limiting feature depends on.
Method 1: Set the bucket ACL to private
Set the bucket ACL to private to stop anonymous access to your OSS resources from the Internet.
If your bucket has public-read permission and its URL is exposed on the Internet, any user on the Internet can access your OSS resources. Private permission provides higher security than public-read permission. After you set the bucket ACL to private, users on the Internet can no longer access the objects in the bucket anonymously.
For more information, see Bucket ACL.
Method 2: Connect the bucket to WAF and configure mitigation policies
Route access to the bucket through a custom domain name that is protected by WAF 3.0, and then configure mitigation policies for that domain name.
Prepare the WAF instance and the custom domain name
Purchase a WAF 3.0 instance. For instructions, see Purchase a WAF 3.0 instance.
Bind a custom domain name to the target bucket in the OSS console.
ImportantWhen you bind the custom domain name, do not resolve the CNAME to the bucket domain name.
For more information, see Access OSS through a custom domain name.
Connect to WAF 3.0 by using a CNAME
Complete the following operations in the Web Application Firewall console and the Alibaba Cloud DNS console:
In the Web Application Firewall console, add the domain name.
Use the custom domain name as the domain name to be protected and use the bucket domain name as the origin server domain name. For instructions, see Add a domain name.
Copy the WAF CNAME address of the domain name.
In the left-side navigation pane, choose Provisioning > CNAME Access.
In the Domain/CNAME list, find the domain name that you added, and view and copy its WAF CNAME address.

In the Alibaba Cloud DNS console, add a CNAME record for the custom domain name that points to the CNAME address provided by WAF.
For instructions, see Change the DNS of a domain name.

Configure mitigation policies
After the domain name is added to WAF, WAF automatically adds it as a protected object and enables Basic Protection Rule. By default, the Medium Rule Group is enabled and the Block mode is adopted.
To limit the request rate for the protected object, configure a Rate Limiting mitigation policy for it. For the mitigation policies that WAF supports, see Custom rules. For instructions, see Configure mitigation policies.
Method 3: Add your site to ESA for network-wide rate limiting
ESA is an Alibaba Cloud edge security product that provides a network-wide rate limiting feature. After you add your site to ESA, ESA can apply frequency control to requests from the same IP address or the same session. When the access frequency exceeds a specified threshold, ESA automatically performs a protective action, such as blocking the request or triggering CAPTCHA verification, to prevent flood attacks.
For more information, see ESA security protection.