Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: Mitigating XSS in the mod_perl API: msg#00128

apache.mod-perl.devel

Subject: Re: Mitigating XSS in the mod_perl API

On Tue, Jan 28, 2003 at 11:30:18AM +0000, Matt Sergeant wrote:
> Here's the patch in case anyone is interested in applying it to their own
> apache. I think there's probably a bug in that \n might not always be the
> right thing to look for (CRLF issues), so please send me corrections ;-)
>
> I haven't actually run this, so it might not work. But to quote Lord
> Flashheart: "That's the kind of guy I am". :-)
>
> Index: src/main/http_protocol.c
> ===================================================================
> RCS file: /home/cvs/apache-1.3/src/main/http_protocol.c,v
> retrieving revision 1.329
> diff -u -r1.329 http_protocol.c
> --- src/main/http_protocol.c 3 Oct 2002 20:51:53 -0000 1.329
> +++ src/main/http_protocol.c 28 Jan 2003 11:26:37 -0000
> @@ -1561,8 +1561,16 @@
> const char *fieldname,
> const char *fieldval)
> {
> + char *line_feed;
> if (strcasecmp(fieldname, "ETag") == 0) {
> if (ap_table_get(r->notes, "no-etag") != NULL) {
> + return 1;
> + }
> + }
> + if ((line_feed = strchr(fieldval, '\n')) != NULL) {
> + /* don't allow any headers with line feeds in them */
> + if (line_feed[1] != ' ' && line_feed[1] != '\t') {
> + /* unless it's a continuation */
> return 1;
> }
> }

I'm wondering if it's not smarter to go over fieldval and at the first
occourance of a \r or \n terminate the line there? I think there will
be more problems by just not outputting the headers in the first place.

Something like:

--- http_protocol.c.old Mon Jan 27 09:45:57 2003
+++ http_protocol.c Tue Jan 28 08:54:37 2003
@@ -1561,10 +1561,14 @@
const char *fieldname,
const char *fieldval)
{
+ char *f;
if (strcasecmp(fieldname, "ETag") == 0) {
if (ap_table_get(r->notes, "no-etag") != NULL) {
return 1;
}
+ }
+ if ((f = strchr(fieldval, '\r')) != NULL || (f = strchr(fieldval, '\n'))
!= NULL) {
+ *f = '\0';
}
return (0 < ap_rvputs(r, fieldname, ": ", fieldval, CRLF, NULL));
}

Of course, a check for continuation like in your patch is needed.

Attached is a module to test it with


Attachment: mod_break.c
Description: Text document

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xxxxxxxxxxxxxxx
For additional commands, e-mail: dev-help@xxxxxxxxxxxxxxx
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
user-groups.jax...    php.zend.framew...    os.solaris.open...    web.quixote.use...    java.openjdk.ho...    ietf.secmech/20...    gnu.glpk/2004-0...    recreation.cars...    network.smokepi...    linux.drivers.i...    cms.opencms.dev...    fonts.gfontview...    text.xml.soap.u...    voip.nist-sip/2...    debian.ports.hp...    xfree86.interna...    science.biology...    qnx.openqnx.dev...    mail.sylpheed.c...    busybox/bios/20...    emulators.kvm.s...    hardware.openco...    apple.fink.begi...    kde.german/2006...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation