Skip to content

Commit 8b1da82

Browse files
committed
fix jsonp rosetta flash vulnerability, see http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
1 parent acfa27a commit 8b1da82

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

lib/MetaCPAN/Server/View/JSONP.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ sub process {
2323
if ( $content_type ne 'application/json' ) {
2424
$body = JSON->new->allow_nonref->ascii->encode($body);
2525
}
26-
$c->res->body("$cb($body);");
26+
$c->res->body("/**/$cb($body);");
2727
return 1;
2828
}
2929

t/server/controller/author.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test_psgi app, sub {
3434
'text/javascript; charset=UTF-8',
3535
'Content-type'
3636
);
37-
like( $res->content, qr/^jsonp\(.*\);$/ms, 'includes jsonp callback' );
37+
like( $res->content, qr/^\/\*\*\/jsonp\(.*\);$/ms, 'includes jsonp callback' );
3838

3939
ok(
4040
$res = $cb->(

t/server/controller/pod.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ test_psgi app, sub {
5959
'text/javascript; charset=UTF-8',
6060
'Content-type'
6161
);
62-
ok( my ($function_args) = $res->content =~ /^foo\((.*)\)/s,
62+
ok( my ($function_args) = $res->content =~ /^\/\*\*\/foo\((.*)\)/s,
6363
'callback included' );
6464
ok( my $jsdata = JSON->new->allow_nonref->decode($function_args),
6565
'decode json' );

t/server/controller/source.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test_psgi app, sub {
4949
)
5050
);
5151
if ( $k =~ /callback=foo/ ) {
52-
ok( my ($function_args) = $res->content =~ /^foo\((.*)\)/s,
52+
ok( my ($function_args) = $res->content =~ /^\/\*\*\/foo\((.*)\)/s,
5353
'JSONP wrapper' );
5454
ok(
5555
my $jsdata
@@ -90,7 +90,7 @@ test_psgi app, sub {
9090
'text/javascript; charset=UTF-8',
9191
'Content-type'
9292
);
93-
ok( my ($function_args) = $res->content =~ /^foo\((.*)\)/s,
93+
ok( my ($function_args) = $res->content =~ /^\/\*\*\/foo\((.*)\)/s,
9494
'JSONP wrapper' );
9595
ok(
9696
my $jsdata = JSON->new->allow_nonref->decode($function_args),

0 commit comments

Comments
 (0)