Skip to content

Commit 1984cfe

Browse files
committed
Merge branch '5.2.x'
2 parents 21b1f30 + a2d516d commit 1984cfe

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ void registerAdapters(ReactiveAdapterRegistry registry) {
413413

414414
/**
415415
* {@code BlockHoundIntegration} for spring-core classes.
416-
* <p>Whitelists the following:
416+
* <p>Explicitly allow the following:
417417
* <ul>
418418
* <li>Reading class info via {@link LocalVariableTableParameterNameDiscoverer}.
419419
* <li>Locking within {@link ConcurrentReferenceHashMap}.

spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void setFavorPathExtension(boolean favorPathExtension) {
196196
* {@code ResourceHttpRequestHandler}.
197197
* <li>Determine the media type of views rendered with
198198
* {@code ContentNegotiatingViewResolver}.
199-
* <li>Whitelist extensions for RFD attack detection (check the Spring
199+
* <li>List safe extensions for RFD attack detection (check the Spring
200200
* Framework reference docs for details).
201201
* </ul>
202202
* @param mediaTypes media type mappings

spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ public ContentNegotiationConfigurer favorPathExtension(boolean favorPathExtensio
162162
* Add a mapping from a key, extracted from a path extension or a query
163163
* parameter, to a MediaType. This is required in order for the parameter
164164
* strategy to work. Any extensions explicitly registered here are also
165-
* whitelisted for the purpose of Reflected File Download attack detection
166-
* (see Spring Framework reference documentation for more details on RFD
167-
* attack protection).
165+
* treated as safe for the purpose of Reflected File Download attack
166+
* detection (see Spring Framework reference documentation for more details
167+
* on RFD attack protection).
168168
* <p>The path extension strategy will also try to use
169169
* {@link ServletContext#getMimeType} and {@link MediaTypeFactory} to resolve path
170170
* extensions. To change this behavior see the {@link #useRegisteredExtensionsOnly} property.

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
7676
implements HandlerMethodReturnValueHandler {
7777

7878
/* Extensions associated with the built-in message converters */
79-
private static final Set<String> WHITELISTED_EXTENSIONS = new HashSet<>(Arrays.asList(
79+
private static final Set<String> SAFE_EXTENSIONS = new HashSet<>(Arrays.asList(
8080
"txt", "text", "yml", "properties", "csv",
8181
"json", "xml", "atom", "rss",
8282
"png", "jpe", "jpeg", "jpg", "gif", "wbmp", "bmp"));
8383

84-
private static final Set<String> WHITELISTED_MEDIA_BASE_TYPES = new HashSet<>(
84+
private static final Set<String> SAFE_MEDIA_BASE_TYPES = new HashSet<>(
8585
Arrays.asList("audio", "image", "video"));
8686

8787
private static final List<MediaType> ALL_APPLICATION_MEDIA_TYPES =
@@ -133,7 +133,7 @@ protected AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>>
133133

134134
this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager());
135135
this.safeExtensions.addAll(this.contentNegotiationManager.getAllFileExtensions());
136-
this.safeExtensions.addAll(WHITELISTED_EXTENSIONS);
136+
this.safeExtensions.addAll(SAFE_EXTENSIONS);
137137
}
138138

139139

@@ -406,8 +406,8 @@ private MediaType getMostSpecificMediaType(MediaType acceptType, MediaType produ
406406
}
407407

408408
/**
409-
* Check if the path has a file extension and whether the extension is
410-
* either {@link #WHITELISTED_EXTENSIONS whitelisted} or explicitly
409+
* Check if the path has a file extension and whether the extension is either
410+
* on the list of {@link #SAFE_EXTENSIONS safe extensions} or explicitly
411411
* {@link ContentNegotiationManager#getAllFileExtensions() registered}.
412412
* If not, and the status is in the 2xx range, a 'Content-Disposition'
413413
* header with a safe attachment file name ("f.txt") is added to prevent
@@ -491,7 +491,7 @@ private MediaType resolveMediaType(ServletRequest request, String extension) {
491491
}
492492

493493
private boolean safeMediaType(MediaType mediaType) {
494-
return (WHITELISTED_MEDIA_BASE_TYPES.contains(mediaType.getType()) ||
494+
return (SAFE_MEDIA_BASE_TYPES.contains(mediaType.getType()) ||
495495
mediaType.getSubtype().endsWith("+xml"));
496496
}
497497

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,15 @@ public void addContentDispositionHeader() throws Exception {
380380
Collections.singletonList(new StringHttpMessageConverter()),
381381
factory.getObject());
382382

383-
assertContentDisposition(processor, false, "/hello.json", "whitelisted extension");
383+
assertContentDisposition(processor, false, "/hello.json", "safe extension");
384384
assertContentDisposition(processor, false, "/hello.pdf", "registered extension");
385385
assertContentDisposition(processor, true, "/hello.dataless", "unknown extension");
386386

387387
// path parameters
388388
assertContentDisposition(processor, false, "/hello.json;a=b", "path param shouldn't cause issue");
389389
assertContentDisposition(processor, true, "/hello.json;a=b;setup.dataless", "unknown ext in path params");
390390
assertContentDisposition(processor, true, "/hello.dataless;a=b;setup.json", "unknown ext in filename");
391-
assertContentDisposition(processor, false, "/hello.json;a=b;setup.json", "whitelisted extensions");
391+
assertContentDisposition(processor, false, "/hello.json;a=b;setup.json", "safe extensions");
392392

393393
// encoded dot
394394
assertContentDisposition(processor, true, "/hello%2Edataless;a=b;setup.json", "encoded dot in filename");

src/docs/asciidoc/web/webmvc.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,11 +1725,11 @@ lower the risk but are not sufficient to prevent RFD attacks.
17251725

17261726
To prevent RFD attacks, prior to rendering the response body, Spring MVC adds a
17271727
`Content-Disposition:inline;filename=f.txt` header to suggest a fixed and safe download
1728-
file. This is done only if the URL path contains a file extension that is neither whitelisted
1729-
nor explicitly registered for content negotiation. However, it can potentially have
1730-
side effects when URLs are typed directly into a browser.
1728+
file. This is done only if the URL path contains a file extension that is neither
1729+
allowed as safe nor explicitly registered for content negotiation. However, it can
1730+
potentially have side effects when URLs are typed directly into a browser.
17311731

1732-
Many common path extensions are whitelisted by default. Applications with custom
1732+
Many common path extensions are allowed as safe by default. Applications with custom
17331733
`HttpMessageConverter` implementations can explicitly register file extensions for content
17341734
negotiation to avoid having a `Content-Disposition` header added for those extensions.
17351735
See <<mvc-config-content-negotiation>>.

0 commit comments

Comments
 (0)