@@ -198,8 +198,9 @@ public String getRecord(
198198 HttpServletRequest request
199199 )
200200 throws Exception {
201+ AbstractMetadata metadata ;
201202 try {
202- ApiUtils .canViewRecord (metadataUuid , request );
203+ metadata = ApiUtils .canViewRecord (metadataUuid , request );
203204 } catch (SecurityException e ) {
204205 Log .debug (API .LOG_MODULE_NAME , e .getMessage (), e );
205206 throw new NotAllowedException (ApiParams .API_RESPONSE_NOT_ALLOWED_CAN_VIEW );
@@ -208,15 +209,16 @@ public String getRecord(
208209 String acceptHeader = StringUtils .isBlank (request .getHeader (HttpHeaders .ACCEPT )) ? MediaType .APPLICATION_XML_VALUE : request .getHeader (HttpHeaders .ACCEPT );
209210 List <String > accept = Arrays .asList (acceptHeader .split ("," ));
210211
211- String formatterBasePath = metadataUuid + "/formatters/" ;
212+ // Use the uuid from the abstract metadata instead of the path variable to address URL forwarding vulnerabilities
213+ String formatterBasePath = metadata .getUuid () + "/formatters/" ;
212214 String defaultFormatterPath = formatterBasePath + "xsl-view" ;
213215 if (accept .contains (MediaType .TEXT_HTML_VALUE ) || accept .contains (MediaType .APPLICATION_XHTML_XML_VALUE )) {
214216 // Check if the language query parameter is a real language supported by the system. If not, fallback to the request language.
215217 String resolvedLanguage = (StringUtils .isNotBlank (language ) && languageUtils .getUiLanguages ().contains (language .toLowerCase ()))
216218 ? language .toLowerCase ()
217219 : languageUtils .getIso3langCode (request .getLocales ());
218220 // If there is a redirect to a record view formatter configured use it, otherwise fallback to the default xsl-view formatter.
219- String redirect = getRecordViewFormatterRedirect (resolvedLanguage , metadataUuid , recordViewFormatter );
221+ String redirect = getRecordViewFormatterRedirect (resolvedLanguage , metadata . getUuid () , recordViewFormatter );
220222 if (StringUtils .isNotBlank (redirect )) {
221223 return redirect ;
222224 }
0 commit comments