Apache2 add module help !

Apache2 add module help !

am 28.10.2009 17:38:15 von Antoine

Hello ,

Consider that i have an html , javascript , php site.

My goal is to somehow modify the html , javascript code before php
module does its stuff.
It is part of a javascript injection defense system. So i want to mark
benign javascript before
php module adds bad javascript code.

I first thought that an output filter is the solution but i suppose that
in the phase of the output filter
the chunks of data will be already produced after php code generation (
is that right ) ?? So the attack
is done and i will mark as benign that bad javascript injection code.

Is there a way to cope with this by adding a module-filter to apache and
not modify php module code ??

Thanks.



------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Apache2 add module help !

am 28.10.2009 17:50:49 von aw

antoine wrote:
> Hello ,
>
> Consider that i have an html , javascript , php site.
>
> My goal is to somehow modify the html , javascript code before php
> module does its stuff.
> It is part of a javascript injection defense system. So i want to mark
> benign javascript before
> php module adds bad javascript code.
>
> I first thought that an output filter is the solution but i suppose that
> in the phase of the output filter
> the chunks of data will be already produced after php code generation (
> is that right ) ??

Yes

So the attack
> is done and i will mark as benign that bad javascript injection code.
>
> Is there a way to cope with this by adding a module-filter to apache and
> not modify php module code ??
>
Apart from the yes above, I cannot add much, because it is not very
clear to me what you are trying to achieve, or what you are trying to
protect against. You seem to say that it is the php which inserts the
"bad" javascript code. But the php runs on your server, so that seems
to be the right point to protect, and not later try to undo what it
might have done. Or do you let any user load its own php stuff onto
your server, and then just run it ?


------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Apache2 add module help !

am 28.10.2009 18:06:34 von Antoine

André Warnier wrote:
> antoine wrote:
>> Hello ,
>>
>> Consider that i have an html , javascript , php site.
>>
>> My goal is to somehow modify the html , javascript code before php
>> module does its stuff.
>> It is part of a javascript injection defense system. So i want to
>> mark benign javascript before
>> php module adds bad javascript code.
>>
>> I first thought that an output filter is the solution but i suppose
>> that in the phase of the output filter
>> the chunks of data will be already produced after php code generation
>> ( is that right ) ??
>
> Yes
>
> So the attack
>> is done and i will mark as benign that bad javascript injection code.
>>
>> Is there a way to cope with this by adding a module-filter to apache
>> and not modify php module code ??
>>
> Apart from the yes above, I cannot add much, because it is not very
> clear to me what you are trying to achieve, or what you are trying to
> protect against. You seem to say that it is the php which inserts the
> "bad" javascript code. But the php runs on your server, so that seems
> to be the right point to protect, and not later try to undo what it
> might have done. Or do you let any user load its own php stuff onto
> your server, and then just run it ?
Ok i will explain. Consider that we have an html form and a php script
that handles the posted data.
The scenario is that the bad guy writes in the form for example
"" and post this
so when the client get the page we have an attack.

So i want to separate the static javascript code from the dynamic one.
I want a filter to process the page before any dynamic content is
inserted for example by php module.


>
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Apache2 add module help !

am 28.10.2009 20:57:50 von mopo

On Wed, 2009-10-28 at 19:06 +0200, antoine wrote:
> Consider that we have an html form and a php script that handles the
> posted data.
> The scenario is that the bad guy writes in the form for example
> "" and post this so when the
> client get the page we have an attack.

Apache is not the right point to protect against things like that. It
would be an ugly hack, which would easily be circumvented by the
attacker.

Use PHP's htmlentities() or strip_tags() on the untrusted data, before
echoing it back to the clients. The manual pages explain how to do this.


Morten

--
Morten K. Poulsen
CTO, FableTech
http://fabletech.com/


------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Apache2 add module help !

am 28.10.2009 21:38:12 von Nick Kew

Morten K. Poulsen wrote:
> On Wed, 2009-10-28 at 19:06 +0200, antoine wrote:
>> Consider that we have an html form and a php script that handles the
>> posted data.
>> The scenario is that the bad guy writes in the form for example
>> "" and post this so when the
>> client get the page we have an attack.
>
> Apache is not the right point to protect against things like that. It
> would be an ugly hack, which would easily be circumvented by the
> attacker.
>
> Use PHP's htmlentities() or strip_tags() on the untrusted data, before
> echoing it back to the clients. The manual pages explain how to do this.

Nevertheless, mod_security offers some protection, where applications
are problematic and can't be fixed.

I don't know if it would help the OP, because I don't know the root
cause of his problem.

--
Nick Kew

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Apache2 add module help !

am 28.10.2009 21:53:20 von Antoine

Nick Kew wrote:
> Morten K. Poulsen wrote:
>> On Wed, 2009-10-28 at 19:06 +0200, antoine wrote:
>>> Consider that we have an html form and a php script that handles the
>>> posted data.
>>> The scenario is that the bad guy writes in the form for example
>>> "" and post this so when the
>>> client get the page we have an attack.
>>
>> Apache is not the right point to protect against things like that. It
>> would be an ugly hack, which would easily be circumvented by the
>> attacker.
>>
>> Use PHP's htmlentities() or strip_tags() on the untrusted data, before
>> echoing it back to the clients. The manual pages explain how to do this.
>
> Nevertheless, mod_security offers some protection, where applications
> are problematic and can't be fixed.
>
> I don't know if it would help the OP, because I don't know the root
> cause of his problem.
>

Thank you guys for your propositions but don't focus in the security model.
In general if i use an input filter can i modify the page's static html code
before any dynamic code is inserted ??





------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Apache2 add module help !

am 28.10.2009 22:06:11 von Nick Kew

antoine wrote:

> Thank you guys for your propositions but don't focus in the security model.
> In general if i use an input filter can i modify the page's static html
> code
> before any dynamic code is inserted ??

If you run PHP as a filter, you could insert another filter in front
of it.

Otherwise, no chance. PHP reads its input straight from your disc.
Any filtering would have to be within the PHP.

--
Nick Kew

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org