1 // Copyright 2018 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_BASE_FEATURES_H_ 6 #define NET_BASE_FEATURES_H_ 7 8 #include <string> 9 10 #include "base/feature_list.h" 11 #include "base/metrics/field_trial_params.h" 12 #include "base/strings/string_piece.h" 13 #include "base/time/time.h" 14 #include "build/build_config.h" 15 #include "crypto/crypto_buildflags.h" 16 #include "net/base/net_export.h" 17 #include "net/net_buildflags.h" 18 19 namespace net::features { 20 21 // Enables ALPS extension of TLS 1.3 for HTTP/2, see 22 // https://vasilvv.github.io/tls-alps/draft-vvv-tls-alps.html and 23 // https://vasilvv.github.io/httpbis-alps/draft-vvv-httpbis-alps.html. 24 NET_EXPORT BASE_DECLARE_FEATURE(kAlpsForHttp2); 25 26 // Disable H2 reprioritization, in order to measure its impact. 27 NET_EXPORT BASE_DECLARE_FEATURE(kAvoidH2Reprioritization); 28 29 // When kCapReferrerToOriginOnCrossOrigin is enabled, HTTP referrers on cross- 30 // origin requests are restricted to contain at most the source origin. 31 NET_EXPORT BASE_DECLARE_FEATURE(kCapReferrerToOriginOnCrossOrigin); 32 33 // Support for altering the parameters used for DNS transaction timeout. See 34 // ResolveContext::SecureTransactionTimeout(). 35 NET_EXPORT BASE_DECLARE_FEATURE(kDnsTransactionDynamicTimeouts); 36 // Multiplier applied to current fallback periods in determining a transaction 37 // timeout. 38 NET_EXPORT extern const base::FeatureParam<double> 39 kDnsTransactionTimeoutMultiplier; 40 NET_EXPORT extern const base::FeatureParam<base::TimeDelta> 41 kDnsMinTransactionTimeout; 42 43 // Enables querying HTTPS DNS records that will affect results from HostResolver 44 // and may be used to affect connection behavior. Whether or not those results 45 // are used (e.g. to connect via ECH) may be controlled by separate features. 46 NET_EXPORT BASE_DECLARE_FEATURE(kUseDnsHttpsSvcb); 47 48 // Param to control whether or not HostResolver, when using Secure DNS, will 49 // fail the entire connection attempt when receiving an inconclusive response to 50 // an HTTPS query (anything except transport error, timeout, or SERVFAIL). Used 51 // to prevent certain downgrade attacks against ECH behavior. 52 NET_EXPORT extern const base::FeatureParam<bool> 53 kUseDnsHttpsSvcbEnforceSecureResponse; 54 55 // If we are still waiting for an HTTPS transaction after all the 56 // other transactions in an insecure DnsTask have completed, we will compute a 57 // timeout for the remaining transaction. The timeout will be 58 // `kUseDnsHttpsSvcbInsecureExtraTimePercent.Get() / 100 * t`, where `t` is the 59 // time delta since the first query began. And the timeout will additionally be 60 // clamped by: 61 // (a) `kUseDnsHttpsSvcbInsecureExtraTimeMin.Get()` 62 // (b) `kUseDnsHttpsSvcbInsecureExtraTimeMax.Get()` 63 // 64 // Any param is ignored if zero, and if one of min/max is non-zero with a zero 65 // percent param it will be used as an absolute timeout. If all are zero, there 66 // is no timeout specific to HTTPS transactions, only the regular DNS query 67 // timeout and server fallback. 68 NET_EXPORT extern const base::FeatureParam<base::TimeDelta> 69 kUseDnsHttpsSvcbInsecureExtraTimeMax; 70 NET_EXPORT extern const base::FeatureParam<int> 71 kUseDnsHttpsSvcbInsecureExtraTimePercent; 72 NET_EXPORT extern const base::FeatureParam<base::TimeDelta> 73 kUseDnsHttpsSvcbInsecureExtraTimeMin; 74 75 // Same as `kUseDnsHttpsSvcbInsecureExtraTime...` except for secure DnsTasks. 76 // 77 // If `kUseDnsHttpsSvcbEnforceSecureResponse` is enabled, the timeouts will not 78 // be used because there is no sense killing a transaction early if that will 79 // just kill the entire request. 80 NET_EXPORT extern const base::FeatureParam<base::TimeDelta> 81 kUseDnsHttpsSvcbSecureExtraTimeMax; 82 NET_EXPORT extern const base::FeatureParam<int> 83 kUseDnsHttpsSvcbSecureExtraTimePercent; 84 NET_EXPORT extern const base::FeatureParam<base::TimeDelta> 85 kUseDnsHttpsSvcbSecureExtraTimeMin; 86 87 // Update protocol using ALPN information in HTTPS DNS records. 88 NET_EXPORT BASE_DECLARE_FEATURE(kUseDnsHttpsSvcbAlpn); 89 90 // If enabled allows the use of SHA-1 by the server for signatures 91 // in the TLS handshake. 92 NET_EXPORT BASE_DECLARE_FEATURE(kSHA1ServerSignature); 93 94 // Enables TLS 1.3 early data. 95 NET_EXPORT BASE_DECLARE_FEATURE(kEnableTLS13EarlyData); 96 97 // Enables the TLS Encrypted ClientHello feature. 98 // https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-13 99 NET_EXPORT BASE_DECLARE_FEATURE(kEncryptedClientHello); 100 101 // Enables the TLS Encrypted ClientHello feature for QUIC. Only takes effect if 102 // kEncryptedClientHello is also enabled. 103 // 104 // TODO(crbug.com/1287248): Remove this flag when ECH for QUIC is fully 105 // implemented. This flag is just a temporary mechanism for now. 106 NET_EXPORT BASE_DECLARE_FEATURE(kEncryptedClientHelloQuic); 107 108 // Enables optimizing the network quality estimation algorithms in network 109 // quality estimator (NQE). 110 NET_EXPORT BASE_DECLARE_FEATURE(kNetworkQualityEstimator); 111 112 // Splits cache entries by the request's includeCredentials. 113 NET_EXPORT BASE_DECLARE_FEATURE(kSplitCacheByIncludeCredentials); 114 115 // Splits cache entries by the request's NetworkIsolationKey if one is 116 // available. 117 NET_EXPORT BASE_DECLARE_FEATURE(kSplitCacheByNetworkIsolationKey); 118 119 // Splits the generated code cache by the request's NetworkIsolationKey if one 120 // is available. Note that this feature is also gated behind 121 // `net::HttpCache::IsSplitCacheEnabled()`. 122 NET_EXPORT BASE_DECLARE_FEATURE(kSplitCodeCacheByNetworkIsolationKey); 123 124 // Splits host cache entries by the DNS request's NetworkIsolationKey if one is 125 // available. Also prevents merging live DNS lookups when there is a NIK 126 // mismatch. 127 NET_EXPORT BASE_DECLARE_FEATURE(kSplitHostCacheByNetworkIsolationKey); 128 129 // Partitions connections based on the NetworkIsolationKey associated with a 130 // request. 131 NET_EXPORT BASE_DECLARE_FEATURE(kPartitionConnectionsByNetworkIsolationKey); 132 133 // Partitions HttpServerProperties based on the NetworkIsolationKey associated 134 // with a request. 135 NET_EXPORT BASE_DECLARE_FEATURE( 136 kPartitionHttpServerPropertiesByNetworkIsolationKey); 137 138 // Partitions TLS sessions and QUIC server configs based on the 139 // NetworkIsolationKey associated with a request. 140 // 141 // This feature requires kPartitionConnectionsByNetworkIsolationKey to be 142 // enabled to work. 143 NET_EXPORT BASE_DECLARE_FEATURE(kPartitionSSLSessionsByNetworkIsolationKey); 144 145 // Partitions Network Error Logging and Reporting API data by 146 // NetworkIsolationKey. Also partitions all reports generated by other consumers 147 // of the reporting API. Applies the NetworkIsolationKey to reports uploads as 148 // well. 149 // 150 // When disabled, the main entry points of the reporting and NEL services ignore 151 // NetworkIsolationKey parameters, and they're cleared while loading from the 152 // cache, but internal objects can be created with them (e.g., endpoints), for 153 // testing. 154 NET_EXPORT BASE_DECLARE_FEATURE(kPartitionNelAndReportingByNetworkIsolationKey); 155 156 // Creates a <double key + is_cross_site> NetworkIsolationKey which is used 157 // to partition the HTTP cache. This key will have the following properties: 158 // `top_frame_site_` -> the schemeful site of the top level page. 159 // `frame_site_` -> absl::nullopt. 160 // `is_cross_site_` -> a boolean indicating whether the frame site is 161 // schemefully cross-site from the top-level site. 162 NET_EXPORT BASE_DECLARE_FEATURE(kEnableCrossSiteFlagNetworkIsolationKey); 163 164 // Enables sending TLS 1.3 Key Update messages on TLS 1.3 connections in order 165 // to ensure that this corner of the spec is exercised. This is currently 166 // disabled by default because we discovered incompatibilities with some 167 // servers. 168 NET_EXPORT BASE_DECLARE_FEATURE(kTLS13KeyUpdate); 169 170 // Enables permuting TLS extensions in the ClientHello, to reduce the risk of 171 // non-compliant servers ossifying parts of the ClientHello and interfering with 172 // deployment of future security improvements. 173 NET_EXPORT BASE_DECLARE_FEATURE(kPermuteTLSExtensions); 174 175 // Enables Kyber-based post-quantum key-agreements in TLS 1.3 connections. 176 NET_EXPORT BASE_DECLARE_FEATURE(kPostQuantumKyber); 177 178 // Changes the timeout after which unused sockets idle sockets are cleaned up. 179 NET_EXPORT BASE_DECLARE_FEATURE(kNetUnusedIdleSocketTimeout); 180 181 // When enabled, the time threshold for Lax-allow-unsafe cookies will be lowered 182 // from 2 minutes to 10 seconds. This time threshold refers to the age cutoff 183 // for which cookies that default into SameSite=Lax, which are newer than the 184 // threshold, will be sent with any top-level cross-site navigation regardless 185 // of HTTP method (i.e. allowing unsafe methods). This is a convenience for 186 // integration tests which may want to test behavior of cookies older than the 187 // threshold, but which would not be practical to run for 2 minutes. 188 NET_EXPORT BASE_DECLARE_FEATURE(kShortLaxAllowUnsafeThreshold); 189 190 // When enabled, the SameSite by default feature does not add the 191 // "Lax-allow-unsafe" behavior. Any cookies that do not specify a SameSite 192 // attribute will be treated as Lax only, i.e. POST and other unsafe HTTP 193 // methods will not be allowed at all for top-level cross-site navigations. 194 // This only has an effect if the cookie defaults to SameSite=Lax. 195 NET_EXPORT BASE_DECLARE_FEATURE(kSameSiteDefaultChecksMethodRigorously); 196 197 #if BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED) 198 NET_EXPORT BASE_DECLARE_FEATURE(kCertDualVerificationTrialFeature); 199 #endif // BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED) 200 201 #if BUILDFLAG(CHROME_ROOT_STORE_OPTIONAL) 202 // When enabled, use the Chrome Root Store instead of the system root store 203 NET_EXPORT BASE_DECLARE_FEATURE(kChromeRootStoreUsed); 204 #endif // BUILDFLAG(CHROME_ROOT_STORE_OPTIONAL) 205 206 // When enabled, TrustStore implementations will use TRUSTED_LEAF, 207 // TRUSTED_ANCHOR_OR_LEAF, and TRUSTED_ANCHOR as appropriate. When disabled, 208 // TrustStore implementation will only use TRUSTED_ANCHOR. 209 // TODO(https://crbug.com/1403034): remove this a few milestones after the 210 // trusted leaf support has been launched on all relevant platforms. 211 #if BUILDFLAG(IS_MAC) || BUILDFLAG(USE_NSS_CERTS) || BUILDFLAG(IS_WIN) 212 NET_EXPORT BASE_DECLARE_FEATURE(kTrustStoreTrustedLeafSupport); 213 #endif 214 215 // Turns off streaming media caching to disk when on battery power. 216 NET_EXPORT BASE_DECLARE_FEATURE(kTurnOffStreamingMediaCachingOnBattery); 217 218 // Turns off streaming media caching to disk always. 219 NET_EXPORT BASE_DECLARE_FEATURE(kTurnOffStreamingMediaCachingAlways); 220 221 // When enabled this feature will cause same-site calculations to take into 222 // account the scheme of the site-for-cookies and the request/response url. 223 NET_EXPORT BASE_DECLARE_FEATURE(kSchemefulSameSite); 224 225 // Enables a process-wide limit on "open" UDP sockets. See 226 // udp_socket_global_limits.h for details on what constitutes an "open" socket. 227 NET_EXPORT BASE_DECLARE_FEATURE(kLimitOpenUDPSockets); 228 229 // FeatureParams associated with kLimitOpenUDPSockets. 230 231 // Sets the maximum allowed open UDP sockets. Provisioning more sockets than 232 // this will result in a failure (ERR_INSUFFICIENT_RESOURCES). 233 NET_EXPORT extern const base::FeatureParam<int> kLimitOpenUDPSocketsMax; 234 235 // Enables a timeout on individual TCP connect attempts, based on 236 // the parameter values. 237 NET_EXPORT BASE_DECLARE_FEATURE(kTimeoutTcpConnectAttempt); 238 239 // FeatureParams associated with kTimeoutTcpConnectAttempt. 240 241 // When there is an estimated RTT available, the experimental TCP connect 242 // attempt timeout is calculated as: 243 // 244 // clamp(kTimeoutTcpConnectAttemptMin, 245 // kTimeoutTcpConnectAttemptMax, 246 // <Estimated RTT> * kTimeoutTcpConnectAttemptRTTMultiplier); 247 // 248 // Otherwise the TCP connect attempt timeout is set to 249 // kTimeoutTcpConnectAttemptMax. 250 NET_EXPORT extern const base::FeatureParam<double> 251 kTimeoutTcpConnectAttemptRTTMultiplier; 252 NET_EXPORT extern const base::FeatureParam<base::TimeDelta> 253 kTimeoutTcpConnectAttemptMin; 254 NET_EXPORT extern const base::FeatureParam<base::TimeDelta> 255 kTimeoutTcpConnectAttemptMax; 256 257 #if BUILDFLAG(ENABLE_REPORTING) 258 // When enabled this feature will allow a new Reporting-Endpoints header to 259 // configure reporting endpoints for report delivery. This is used to support 260 // the new Document Reporting spec. 261 NET_EXPORT BASE_DECLARE_FEATURE(kDocumentReporting); 262 #endif // BUILDFLAG(ENABLE_REPORTING) 263 264 #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) 265 // When enabled, UDPSocketPosix increments the global counter of bytes received 266 // every time bytes are received, instead of using a timer to batch updates. 267 // This should reduce the number of wake ups and improve battery consumption. 268 // TODO(https://crbug.com/1189805): Cleanup the feature after verifying that it 269 // doesn't negatively affect performance. 270 NET_EXPORT BASE_DECLARE_FEATURE(kUdpSocketPosixAlwaysUpdateBytesReceived); 271 #endif // BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) 272 273 // When this feature is enabled, redirected requests will be considered 274 // cross-site for the purpose of SameSite cookies if any redirect hop was 275 // cross-site to the target URL, even if the original initiator of the 276 // redirected request was same-site with the target URL (and the 277 // site-for-cookies). 278 // See spec changes in https://github.com/httpwg/http-extensions/pull/1348 279 NET_EXPORT BASE_DECLARE_FEATURE(kCookieSameSiteConsidersRedirectChain); 280 281 // When this feature is enabled, the SameParty attribute is enabled. (Note that 282 // when this feature is disabled, the SameParty attribute is still parsed and 283 // saved for cookie-sets, but it has no associated semantics (when setting or 284 // reading cookies).) 285 NET_EXPORT BASE_DECLARE_FEATURE(kSamePartyAttributeEnabled); 286 287 // When enabled, sites can opt-in to having their cookies partitioned by 288 // top-level site with the Partitioned attribute. Partitioned cookies will only 289 // be sent when the browser is on the same top-level site that it was on when 290 // the cookie was set. 291 NET_EXPORT BASE_DECLARE_FEATURE(kPartitionedCookies); 292 293 // When enabled, then we allow partitioned cookies even if kPartitionedCookies 294 // is disabled only if the cookie partition key contains a nonce. So far, this 295 // is used to create temporary cookie jar partitions for fenced and anonymous 296 // frames. 297 NET_EXPORT BASE_DECLARE_FEATURE(kNoncedPartitionedCookies); 298 299 // When enabled, cookies cannot have an expiry date further than 400 days in the 300 // future. 301 NET_EXPORT BASE_DECLARE_FEATURE(kClampCookieExpiryTo400Days); 302 303 // Controls whether static key pinning is enforced. 304 NET_EXPORT BASE_DECLARE_FEATURE(kStaticKeyPinningEnforcement); 305 306 // When enabled, cookies with a non-ASCII domain attribute will be rejected. 307 NET_EXPORT BASE_DECLARE_FEATURE(kCookieDomainRejectNonASCII); 308 309 // Blocks the 'Set-Cookie' request header on outbound fetch requests. 310 NET_EXPORT BASE_DECLARE_FEATURE(kBlockSetCookieHeader); 311 312 NET_EXPORT BASE_DECLARE_FEATURE(kThirdPartyStoragePartitioning); 313 NET_EXPORT BASE_DECLARE_FEATURE(kSupportPartitionedBlobUrl); 314 315 // Whether ALPS parsing is on for any type of frame. 316 NET_EXPORT BASE_DECLARE_FEATURE(kAlpsParsing); 317 318 // Whether ALPS parsing is on for client hint parsing specifically. 319 NET_EXPORT BASE_DECLARE_FEATURE(kAlpsClientHintParsing); 320 321 // Whether to kill the session on Error::kAcceptChMalformed. 322 NET_EXPORT BASE_DECLARE_FEATURE(kShouldKillSessionOnAcceptChMalformed); 323 324 NET_EXPORT BASE_DECLARE_FEATURE(kCaseInsensitiveCookiePrefix); 325 326 NET_EXPORT BASE_DECLARE_FEATURE(kEnableWebsocketsOverHttp3); 327 328 // Whether to do IPv4 to IPv6 address translation for IPv4 literals. 329 NET_EXPORT BASE_DECLARE_FEATURE(kUseNAT64ForIPv4Literal); 330 331 // Whether to block newly added forbidden headers (https://crbug.com/1362331). 332 NET_EXPORT BASE_DECLARE_FEATURE(kBlockNewForbiddenHeaders); 333 334 #if BUILDFLAG(IS_WIN) 335 // Whether to probe for SHA-256 on some legacy platform keys, before assuming 336 // the key requires SHA-1. See SSLPlatformKeyWin for details. 337 NET_EXPORT BASE_DECLARE_FEATURE(kPlatformKeyProbeSHA256); 338 #endif 339 340 // Enable support for HTTP extensible priorities (RFC 9218) 341 // https://crbug.com/1362031 342 NET_EXPORT BASE_DECLARE_FEATURE(kPriorityIncremental); 343 344 // Prefetch to follow normal semantics instead of 5-minute rule 345 // https://crbug.com/1345207 346 NET_EXPORT BASE_DECLARE_FEATURE(kPrefetchFollowsNormalCacheSemantics); 347 348 // A flag for new Kerberos feature, that suggests new UI 349 // when Kerberos authentication in browser fails on ChromeOS. 350 // b/260522530 351 #if BUILDFLAG(IS_CHROMEOS) 352 NET_EXPORT BASE_DECLARE_FEATURE(kKerberosInBrowserRedirect); 353 #endif 354 355 // A flag to use asynchronous session creation for new QUIC sessions. 356 NET_EXPORT BASE_DECLARE_FEATURE(kAsyncQuicSession); 357 358 // Enables custom proxy configuration for the IP Protection experimental proxy. 359 NET_EXPORT BASE_DECLARE_FEATURE(kEnableIpProtectionProxy); 360 361 // Sets the name of the IP protection proxy. 362 NET_EXPORT extern const base::FeatureParam<std::string> kIpPrivacyProxyServer; 363 364 // Sets the allow list for the IP protection proxy. 365 NET_EXPORT extern const base::FeatureParam<std::string> 366 kIpPrivacyProxyAllowlist; 367 368 // Whether QuicParams::migrate_sessions_on_network_change_v2 defaults to true or 369 // false. This is needed as a workaround to set this value to true on Android 370 // but not on WebView (until crbug.com/1430082 has been fixed). 371 NET_EXPORT BASE_DECLARE_FEATURE(kMigrateSessionsOnNetworkChangeV2); 372 373 #if BUILDFLAG(IS_LINUX) 374 // AddressTrackerLinux will not run inside the network service in this 375 // configuration, which will improve the Linux network service sandbox. 376 // TODO(crbug.com/1312226): remove this. 377 NET_EXPORT BASE_DECLARE_FEATURE(kAddressTrackerLinuxIsProxied); 378 #endif // BUILDFLAG(IS_LINUX) 379 380 } // namespace net::features 381 382 #endif // NET_BASE_FEATURES_H_ 383