Skip to content

Commit

Permalink
Updated the adaptors to have a config.h preproc definition which, if …
Browse files Browse the repository at this point in the history
…enabled, compiles the adaptors without the ability to check for invalid URL characters.
  • Loading branch information
NotsoanoNimus committed Aug 4, 2022
1 parent a274dad commit 23c9775
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Utilities/Adaptors/Adaptor/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ typedef int intptr_t;
#define WA_MAX_HOST_NAME_LENGTH 64 /* maximum length of a host name, including the null */
#define WA_MAX_INSTANCE_NUMBER_LENGTH 8 /* maximum length of an instance number, including the null */


// 2022-08-04: Uncomment this option to explicitly DISABLE URL invalid character rejections.
// Please do not change this unless you are certain about doing so!
//#define __PRESERVE_UNSAFE_URLS 1

/*
* default values for some feature settings
*/
Expand Down
12 changes: 12 additions & 0 deletions Utilities/Adaptors/Apache/mod_WebObjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,24 @@ int WebObjects_translate(request_rec *r) {
WebObjects_config *wc;
WOURLComponents url;
WOURLError urlerr;
WOURLError charcheck;

wc = (WebObjects_config *)ap_get_module_config(r->server->module_config, &WebObjects_module);

/* WOLog(WO_DBG,"<WebObjects Apache Module> new translate: %s",r->uri); */
if (strncmp(wc->WebObjects_alias, r->uri, strlen(wc->WebObjects_alias)) == 0) {
url = WOURLComponents_Initializer;

#ifndef __PRESERVE_UNSAFE_URLS
// Make sure the URL does not contain forbidden characters (0x0D or 0x0A).
charcheck = WOValidateInitialURL( r->uri );
if ( charcheck != WOURLOK ) {
WOLog(WO_ERR, "WebObjects_translate(): declining request due to forbidden URL characters");
return DECLINED;
}
#endif


urlerr = WOParseApplicationName(&url, r->uri);
if (urlerr != WOURLOK && !((urlerr == WOURLInvalidApplicationName) && ac_authorizeAppListing(&url))) {
/* WOLog(WO_DBG,"<WebObjects Apache Module> translate - DECLINED: %s",r->uri); */
Expand Down
4 changes: 3 additions & 1 deletion Utilities/Adaptors/Apache2.2/mod_WebObjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,14 @@ int WebObjects_translate(request_rec *r) {
memset(&url,0,sizeof(WOURLComponents));
#endif

#ifndef __PRESERVE_UNSAFE_URLS
// Make sure the URL does not contain forbidden characters (0x0D or 0x0A).
charcheck = WOValidateInitialURL( r->uri );
if ( charcheck != WOURLOK ) {
WOLog(WO_DBG, "WebObjects_translate(): declining request due to forbidden URL characters");
WOLog(WO_ERR, "WebObjects_translate(): declining request due to forbidden URL characters");
return DECLINED;
}
#endif

urlerr = WOParseApplicationName(&url, r->uri);
if (urlerr != WOURLOK && !((urlerr == WOURLInvalidApplicationName) && ac_authorizeAppListing(&url))) {
Expand Down
4 changes: 3 additions & 1 deletion Utilities/Adaptors/Apache2.4/mod_WebObjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,14 @@ int WebObjects_translate(request_rec *r) {
memset(&url,0,sizeof(WOURLComponents));
#endif

#ifndef __PRESERVE_UNSAFE_URLS
// Make sure the URL does not contain forbidden characters (0x0D or 0x0A).
charcheck = WOValidateInitialURL( r->uri );
if ( charcheck != WOURLOK ) {
WOLog(WO_DBG, "WebObjects_translate(): declining request due to forbidden URL characters");
WOLog(WO_ERR, "WebObjects_translate(): declining request due to forbidden URL characters");
return DECLINED;
}
#endif

urlerr = WOParseApplicationName(&url, r->uri);
if (urlerr != WOURLOK && !((urlerr == WOURLInvalidApplicationName) && ac_authorizeAppListing(&url))) {
Expand Down
2 changes: 2 additions & 0 deletions Utilities/Adaptors/CGI/WebObjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ int doit(int argc, char *argv[], char **envp) {
strcat(url, path_info);
WOLog(WO_INFO,"<CGI> new request: %s",url);

#ifndef __PRESERVE_UNSAFE_URLS
// Make sure the URL does not contain forbidden characters (0x0D or 0x0A).
charcheck = WOValidateInitialURL( url );
if ( charcheck != WOURLOK ) {
Expand All @@ -324,6 +325,7 @@ int doit(int argc, char *argv[], char **envp) {
_urlerr = WOURLstrerror( charcheck );
die( _urlerr, HTTP_BAD_REQUEST );
}
#endif

urlerr = WOParseApplicationName(&wc, url);
if (urlerr != WOURLOK) {
Expand Down
2 changes: 2 additions & 0 deletions Utilities/Adaptors/FastCGI/WebObjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ int main() {
strcat(url, path_info);
WOLog(WO_INFO,"<FastCGI> new request: %s",url);

#ifndef __PRESERVE_UNSAFE_URLS
// Make sure the URL does not contain forbidden characters (0x0D or 0x0A).
charcheck = WOValidateInitialURL( url );
if ( charcheck != WOURLOK ) {
Expand All @@ -341,6 +342,7 @@ int main() {
WOFREE(url);
break;
}
#endif

urlerr = WOParseApplicationName(&wc, url);
if (urlerr != WOURLOK) {
Expand Down
2 changes: 2 additions & 0 deletions Utilities/Adaptors/IIS/WebObjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ __declspec(dllexport) DWORD __stdcall HttpExtensionProc(EXTENSION_CONTROL_BLOCK
WOLog(WO_INFO,"<WebObjects ISAPI> new request: %s", uri);
WOFREE(script_name);

#ifndef __PRESERVE_UNSAFE_URLS
// Make sure the URL does not contain forbidden characters (0x0D or 0x0A).
charcheck = WOValidateInitialURL( uri );
if ( charcheck != WOURLOK ) {
Expand All @@ -636,6 +637,7 @@ __declspec(dllexport) DWORD __stdcall HttpExtensionProc(EXTENSION_CONTROL_BLOCK
_urlerr = WOURLstrerror( charcheck );
return die( p, _urlerr, HTTP_BAD_REQUEST );
}
#endif

urlerr = WOParseApplicationName(&wc, uri);
if (urlerr != WOURLOK) {
Expand Down

0 comments on commit 23c9775

Please sign in to comment.