Help Center/ Object Storage Service/ User Guide/ Data Security/ Configuring URL Validation to Prevent Unauthorized Access to Your Data
Updated on 2026-08-21 GMT+08:00

Configuring URL Validation to Prevent Unauthorized Access to Your Data

OBS blocks access requests from blacklisted URLs and allows those from whitelisted URLs.

Scenarios

Some rogue websites may steal links from other websites to enrich their content without any costs. Link stealing hurts the interests of the original websites and it is also a strain on their servers. URL validation is designed to address this issue.

In HTTP, the Referer field allows websites and web servers to identify where people are visiting them from. URL validation of OBS utilizes this Referer field. The idea is that once you find that a request to your resource is not originated from an authorized source, you can have the request blocked or redirected to a specific web page. This way, OBS prevents unauthorized access to data stored in buckets.

Referers can be configured using a whitelist or blacklist.

Referer Rules

  • The total length of the Referers in a whitelist or blacklist cannot exceed 1,024 characters.
  • Referer format:
    • You can enter multiple Referers, with each one on a separate line.
    • A Referer can contain wildcards (*) and question marks (?). A wildcard can match zero or more characters and a question mark (?) can match a single character.
    • If the Referer header contains http or https during a download, the Referer configuration must also contain http or https.
  • If the Referer whitelist is empty while the blacklist is not, all websites except those listed in the blacklist are allowed to access the target bucket.
  • If the Referer whitelist is not empty, regardless of whether the blacklist is empty or not, only websites that appear in the whitelist and do not appear in the blacklist are allowed to access the target bucket.
  • If a Referer appears in both the whitelist and the blacklist, that Referer is denied. For example, if both the whitelist and the blacklist contain https://www.example.com, requests from that website will be blocked.
  • If both the Referer whitelist and blacklist are empty, all websites are allowed to access the target bucket by default.
  • Before determining whether a user has the four types of permissions (read, write, ACL read, and ACL write) for a bucket and its objects, check whether this user complies with the URL validation rules defined in the Referer field.
  • The Referer supports wildcard domain names.

Important Notes

  • Risk of bypassing URL validation via CDN caching: If both URL validation and CDN acceleration domain names are configured for an OBS bucket, an unauthorized request to OBS may directly hit the CDN cache node and obtain the cached content without triggering OBS validation. To ensure complete and effective protection, you must also configure URL validation rules on CDN. For details, see Filtering Requests from Specific Referers.
  • Impact of browser Referrer-Policy: Modern browsers support the Referrer-Policy response header, which allows websites to control how the Referer header is sent in cross-domain requests. Under certain policies, such as no-referrer, the browser suppresses the Referer header, and OBS processes it as a null Referer. When configuring URL validation, you need to take this behavior into consideration (for example, when configuring whitelisted Referers, enable Null referer is allowed).
  • Video playback compatibility: When a browser uses the native <video> tag to play videos, it sends requests to the video server to obtain media data. The Referers of these requests may be null or point to other pages. Therefore, OBS must allow access from null Referers (when configuring whitelisted Referers, enable Null referer is allowed). Otherwise, video playback will fail.

Prerequisites

Static website hosting has been enabled.

Ways to Configure URL Validation

You can use OBS Console or APIs to configure URL validation.

Example Scenarios

The following are common application scenarios of URL validation:

Allowing Only Trusted Websites to Access OBS

The URL validation whitelist allows access to OBS exclusively from trusted Referers that frequently request OBS buckets. You can whitelist specific Referers to allow access to OBS from trusted websites.

  1. View the bucket logs and find the value of the Referer field in the bucket log file. For details about bucket logging, see Logging Overview.

    If the value of the Referer field in the bucket log file is -, the Referer is null.

  2. Configure URL validation rules for the bucket.

    For details about the configuration procedure, see Using OBS Console. Table 1 describes the parameters.

    Table 1 URL validation whitelist rules

    Parameter

    Value

    Description

    Whitelisted Referers

    https://www.example.com
    http://www.example.com
    https://console.huaweicloud.com/*
    • Add the domain names of trusted websites that frequently access OBS buckets.
    • You are advised to add both HTTPS and HTTP domain names.
    • Add the domain name of the console and use the wildcard (*), ensuring that the console in any region can be properly previewed.

    Null referer is allowed

    Toggle it on.

    Ensure that both direct access and console preview functions work properly.

    Blacklisted Referers

    Leave it blank.

    You do not need to block specific sources.

  3. Verify the configuration.

    • Simulate a request with a whitelisted Referer to OBS. The request is expected to be successful.
    • Simulate a request with a non-whitelisted Referer to OBS. The request is expected to fail, and AccessDenied is returned.
    • Simulate a request with a null Referer to OBS. The request is expected to be successful.

Preventing Malicious Websites from Stealing OBS Data

Access from all sources is allowed, but some malicious websites must be prohibited from stealing OBS data. You can blacklist specific Referers to precisely block malicious access sources.

  1. View logs about abnormal traffic of the OBS bucket and find the value of the Referer field in the bucket log file. For details about bucket logging, see Logging Overview.
  2. Configure URL validation rules for the bucket.

    For details about the configuration procedure, see Using OBS Console. Table 2 describes the parameters.

    Table 2 URL validation blacklist rules

    Parameter

    Value

    Description

    Whitelisted Referers

    *

    Allow access from any sources to OBS.

    Null referer is allowed

    Toggle it on.

    Ensure that both direct access to OBS and access via normal clients are allowed.

    Blacklisted Referers

    https://badmail.example.com
    http://badmail.example.com
    *badsite.example

    Block access from malicious website domain names. The wildcard (*) indicates that the entire domain name and its subdomains are blocked.

  3. Verify the configuration.

    • Simulate a request from a trusted website to OBS. The request is expected to be successful.
    • Simulate a request with a blacklisted Referer to OBS. The request is expected to fail, and AccessDenied is returned.
    • Simulate a request with a null Referer to OBS. The request is expected to be successful.

Accessing OBS Using Mini Programs

The URL validation whitelist allows access to OBS exclusively from a specific mini program (for example, https://appexample.com/{appid}/{version}/page-example.html). You can whitelist specific Referers to allow access to OBS from the mini program.

  1. Obtain the domain name of the mini program and use the wildcard (*) to match all subdomains of the mini program.

    You can view the logs about the mini program's access to the OBS bucket and find the value of the Referer field in the bucket log file. For details about bucket logging, see Logging Overview.

  2. Configure URL validation rules for the bucket.

    For details about the configuration procedure, see Using OBS Console. Table 3 describes the parameters.

    Table 3 URL validation whitelist rules

    Parameter

    Value

    Description

    Whitelisted Referers

    *appexample.com
    https://console.huaweicloud.com/*
    • Use the wildcard (*) to match all subdomains of the mini program.
    • Add the domain name of the console and use the wildcard (*), ensuring that the console in any region can be properly previewed.

    Null referer is allowed

    Toggle it on.

    In some cases, the mini program may not send a Referer. Enabling this function ensures compatibility.

    Blacklisted Referers

    Leave it blank.

    You do not need to block specific sources.

  3. Verify the configuration.

    • Use the mini program to access OBS. The access is expected to be successful.
    • Simulate a request with a non-whitelisted Referer to OBS. The request is expected to fail, and AccessDenied is returned.
    • Use the mini program to access OBS (without a Referer). The access is expected to be successful.

Allowing Object Preview and Download on the OBS Console

With the URL validation whitelist, you can add the OBS console domain name to the whitelisted Referers to ensure normal management functions.

  1. Configure URL validation rules for the bucket.

    For details about the configuration procedure, see Using OBS Console. Table 4 describes the parameters.

    Table 4 URL validation whitelist rules

    Parameter

    Value

    Description

    Whitelisted Referers

    https://console.huaweicloud.com/*

    Add the domain name of the console and use the wildcard (*) to match all its subdomains, ensuring that the console in any region can be properly previewed.

    Null referer is allowed

    Toggle it on.

    Ensure that both direct access and console preview functions work properly.

    Blacklisted Referers

    Leave it blank.

    You do not need to block specific sources.

  2. Verify the configuration.

    Simulate access to the console. The access is expected to be successful. You can also preview and download files on the OBS console for verification.

Prohibiting Direct Access to OBS Via URLs

All access to OBS must come from specified websites. Direct access via URLs is prohibited.

This configuration will block null Referers, indicating that all direct access requests are prohibited. Since bookmarks, email links, and some browser plug-ins, download tools, or video players typically do not include Referers in their requests, these components may not function properly.

  1. Determine the Referer of a specified website.

    Identify all possible combinations of domain names and protocols for the website to ensure that all legitimate access scenarios are covered.

  2. Configure URL validation rules for the bucket.

    For details about the configuration procedure, see Using OBS Console. Table 5 describes the parameters.

    Table 5 URL validation whitelist rules

    Parameter

    Value

    Description

    Whitelisted Referers

    https://www.example.com
    http://www.example.com
    https://console.huaweicloud.com/*
    • Identify all possible combinations of domain names and protocols for the website to ensure that all legitimate access scenarios are covered.
    • You are advised to add both HTTPS and HTTP domain names.
    • Add the domain name of the console and use the wildcard (*) to ensure that objects can be properly previewed on the console in any region.

    Null referer is allowed

    Toggle it off.

    Disabling this function can prevent direct access to OBS resources through URLs in the address bar.

    Blacklisted Referers

    Leave it blank.

    You do not need to block specific sources.

  3. Verify the configuration.

    • Simulate a request from a specified website to access OBS. The request is expected to be successful.
    • Simulate a request to access OBS directly through a URL in the address bar. The request is expected to fail, and AccessDenied is returned.
    • Simulate a request from another website to OBS. The request is expected to fail, and AccessDenied is returned.