Here is another security issues with ad_returnredirect: Header Injection
ad_returnredirect doesn't check the URL parameter for \n line breaks and so allows to modify the header of the response. Here is the explanation:
HTTP header injection vulnerabilities arise when user-supplied data is copied into a response header in an unsafe way. If an attacker can inject newline characters into the header, then they can inject new HTTP headers and also, by injecting an empty line, break out of the headers into the message body and write arbitrary content into the application's response. Various kinds of attack can be delivered via HTTP header injection vulnerabilities. Any attack that can be delivered via cross-site scripting can usually be delivered via header injection, because the attacker can construct a request which causes arbitrary JavaScript to appear within the response body. Further, it is sometimes possible to leverage header injection vulnerabilities to poison the cache of any proxy server via which users access the application. Here, an attacker sends a crafted request which results in a "split" response containing arbitrary content. If the proxy server can be manipulated to associate the injected response with another URL used within the application, then the attacker can perform a "stored" attack against this URL which will compromise other users who request that URL in future. The value of the return%5furl request parameter is copied into the Location response header.
You can test this behavior on any ]po[ page (for example: http://po40demo.project-open.net/intranet/, email=bbigboss@tigerpond.com, passwd=ben). Then enter the URL: /intranet/biz-object-tree-open-close?open%5fp=c&return%5furl=b5a54%0d%0aa882d&object%5fid=29137&page%5furl=default&user%5fid=624
The resulting HTTP response contains:
- b5a54
- a882d
The problem occurs because ad_returnredirect passes on the %0d and %0a characters to the response header. So sanitizing the return_url this way should be mostly harmless and be a security enhancement for OpenACS 5.8, isn't it?
Cheers!
Frank