You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Eiji Kitamura <ag...@gmail.com> on 2009/06/03 05:31:54 UTC

Why rebuilding post body params?

Hi,


I have question regarding post body params via gadgets.io.makeRequest.

I found PHP Shindig breaks posted params when it includes "%3D".
For example, when I try to post something like:

var post_data = gadgets.io.encodeValues({'message' : '1 + 1 = 2'});
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
params[gadgets.io.RequestParameters.POST_DATA] = post_data;
gadgets.io.makeRequest(url, callback, params);

This request is supposed to proxy params as
"message=1+%2B+1+%3D+2"

But on PHP Shindig, it turns out to be nothing.
This is because PHP Shindig is trying to explode('=', value) after urldecoding.
"message=1 + 1 = 2"

Here's code in php/src/gadgets/ProxyBase.php:

$entry = urldecode($entry);
$parts = explode('=', $entry);
// Process only if its a valid value=something pair
if (count($parts) == 2) {
  $postData .= urlencode($parts[0]) . '=' . urlencode($parts[1]) . '&';
}

So I come up with following patch:
https://issues.apache.org/jira/browse/SHINDIG-1069

My solution is to pass the post body as is since I don't know why you
have to rebuild the post body.
Maybe a security risk?

Can any one tell me why shindig is rebuilding post body param?
If there's any security risk, alternative patch should be something
that removes urldecode part?
-  $entry = urldecode($entry);

Re: Why rebuilding post body params?

Posted by Chris Chabot <ch...@google.com>.
Hey Eiji,

With the I/O and everything it's taken me a bit to catch up with the mail
backlog, sorry it took a bit :)

I've quickly looked through that code, and I don't really see any place
where we add anything to the post data, so it doesn't seem to be a tampering
security issue; I'll have to go through the makeRequest javascript
implementation code too to see if it always builds a proper url-formencoded
post, or if it actually allows raw post bodies (say a raw json or xml
structure).

If the javascript impl. does allow raw posts, there's really no need for the
post-rebuilding-code, however if it doesn't, it's a good way to sanity
check.

I'll get back to you on this later this week

   -- Chris

On Wed, Jun 3, 2009 at 5:31 AM, Eiji Kitamura <ag...@gmail.com> wrote:

> Hi,
>
>
> I have question regarding post body params via gadgets.io.makeRequest.
>
> I found PHP Shindig breaks posted params when it includes "%3D".
> For example, when I try to post something like:
>
> var post_data = gadgets.io.encodeValues({'message' : '1 + 1 = 2'});
> params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
> params[gadgets.io.RequestParameters.POST_DATA] = post_data;
> gadgets.io.makeRequest(url, callback, params);
>
> This request is supposed to proxy params as
> "message=1+%2B+1+%3D+2"
>
> But on PHP Shindig, it turns out to be nothing.
> This is because PHP Shindig is trying to explode('=', value) after
> urldecoding.
> "message=1 + 1 = 2"
>
> Here's code in php/src/gadgets/ProxyBase.php:
>
> $entry = urldecode($entry);
> $parts = explode('=', $entry);
> // Process only if its a valid value=something pair
> if (count($parts) == 2) {
>  $postData .= urlencode($parts[0]) . '=' . urlencode($parts[1]) . '&';
> }
>
> So I come up with following patch:
> https://issues.apache.org/jira/browse/SHINDIG-1069
>
> My solution is to pass the post body as is since I don't know why you
> have to rebuild the post body.
> Maybe a security risk?
>
> Can any one tell me why shindig is rebuilding post body param?
> If there's any security risk, alternative patch should be something
> that removes urldecode part?
> -  $entry = urldecode($entry);
>