Skip Menu |

This queue is for tickets about the Parse-BBCode CPAN distribution.

Maintainer(s)' notes

If you have any wishes, feel free to create a ticket.

Plans:

I would like to add callbacks to the parser so that you can gather some information about specific tags and ideally can manipulate them during parsing.

But there are already enough informations to create a download link for code tags, for example. See example/code_download.pl.

Parse::BBCode is now hosted on github, so for bug reports also check https://github.com/perlpunk/Parse-BBCode

Report information
The Basics
Id: 62617
Status: resolved
Priority: 0/
Queue: Parse-BBCode

People
Owner: TINITA [...] cpan.org
Requestors: sflex [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.03
  • 0.04
  • 0.05
  • 0.06
  • 0.07
  • 0.08
  • 0.09
  • 0.10
  • 0.11
Fixed in: 0.12



Subject: Multiple XSS security issues
The security you are using to stop JavaScript can be bypassed!
Am Mo 01. Nov 2010, 08:47:36, SFLEX schrieb: Show quoted text
> The security you are using to stop JavaScript can be bypassed!
sflex, you got so much help with your own module on perlmonks, you even copied my benchmark script into your package with a few changes without mentioning. you think you are cool by creating bug reports without telling details? you're rating your own module, seeking for help/advice on perlmonks regularly, but you haven't learned giving back to the community. you don't even care when a number of people is telling you that you shouldn't rate your own module. and now you are telling me my module has bugs but don't tell me which. you're such a great help, sflex! community can be glad it has such a generous member.
On Tue Nov 16 06:55:03 2010, TINITA wrote: Show quoted text
> Am Mo 01. Nov 2010, 08:47:36, SFLEX schrieb:
> > The security you are using to stop JavaScript can be bypassed!
> > sflex, you got so much help with your own module on perlmonks, you
even Show quoted text
> copied my benchmark script into your package with a few changes
without Show quoted text
> mentioning. > > you think you are cool by creating bug reports without telling
details? Show quoted text
> > you're rating your own module, seeking for help/advice on perlmonks > regularly, but you haven't learned giving back to the community. you > don't even care when a number of people is telling you that you > shouldn't rate your own module. > > and now you are telling me my module has bugs but don't tell me which. > > you're such a great help, sflex! > community can be glad it has such a generous member.
It took you 16 days before you read this bug and I had to tell you at perlmonks to look at your modules bug report. So for 16 day's and more the full exploit could have been sitting here for every hacker to see and all your users of this module would be even more at risk. But since I was more thoughtful then you seem to think I am. i was just waiting for you to ask me "how to do it". Instead you rant about things that are unproductive and maybe in your mind will try to make me mad. If you remember my first post for Bench this BBcode at perlmonks I gave you credit for the bench code that some other monk helped you with but you want credit for it when I use it in my module's example folder. You have already rated your own module because you lie in the file compare.html about other modules that you cant use to well or have a bias opinion of other modules like my AUBBC. Like I said in Bench this BBcode, "I would like to help the other bbcode authors of Perl." But after having to deal with you. You can stay under you little rock and dwell on the past. Your really good at that, trust me.
ok, so I take that as "cannot deliver details". no bug, no fix. Show quoted text
> You have already rated your own module because you lie in the file > compare.html about other modules that you cant use to well or have a > bias opinion of other modules like my AUBBC.
my comparison is as objective as possible and it says that anybody should feel free to correct anything in the comparison that seems wrong, and I'll have a look at it. if you have any concrete objection to that comparison open a bug report and post details. thank you very much for your patience and have fun with AUBBC.
On Tue Nov 16 08:27:16 2010, TINITA wrote: Show quoted text
> ok, so I take that as "cannot deliver details". > no bug, no fix. >
> > You have already rated your own module because you lie in the file > > compare.html about other modules that you cant use to well or have
a Show quoted text
> > bias opinion of other modules like my AUBBC.
> > my comparison is as objective as possible and it says that anybody
should Show quoted text
> feel free to correct anything in the comparison that seems wrong, and > I'll have a look at it. > > if you have any concrete objection to that comparison open a bug
report Show quoted text
> and post details. > > thank you very much for your patience and have fun with AUBBC.
You are not much of a CPAN author if your going to reject a security issue with your own program. Don't think you can delete this report because you actually do have a security hole and all I was waiting for was you to simply ask me to show you how its done. Instead I think I will wait for you to apologize to me before I show you how your module can be hacked and if you feel the want to reject this post, well....
If there is a bug, just show it. Your behaviour on perlmonks was so disgusting that you have no right at all to demand an apology from me. What kind of world do you think you live in? A world where you are free to offend others, but others are required to apologize? You had several chances to remove your cpanrating. If you don't post the bug, I cannot fix it. Plain, simple. And if you don't want to post it, then leave me alone. I don't know why you are stalking me since that one posting on perlmonks where I said it's considered unpolite to rate your own module. If you don't post it, then I believe that you are lying. What reason would you have to not post a bug?
Subject: It was to easy to find in the first place!
This hack is so basic I cant believe you didn't come across it yourself. Here is the hack below: [img]jav	ascript:alert(String.fromCharCode(88,83,83))[/img] [img]jav
ascript:alert(String.fromCharCode(88,83,83))[/img] [url=jav
ascript:alert(String.fromCharCode(88,83,83))]Look what I can do![/url] [url=jav	ascript:alert(String.fromCharCode(88,83,83))]Look what I can do![/url] My suggested fix for this issue: Changes to file 'lib/Parse/BBCode/HTML.pm' File version '0.04' Starts at about line 64 # XSS Fix link => sub { my ($p, $tag, $var) = @_; $var = Parse::BBCode::escape_html($var); $var =~ m{\A\w+://|/}i ? return $var : return ''; }, This fix will now stop any JavaScript plus allow local linking like: [img]/images/some.gif[/img] For href's you need to specify a protocol like http, ftp for it to be valid. This is why you do not want to use the same filter for the image tag and url tag. the image HTML element uses 'src' and the url uses 'href' these two attributes have different functions. For example image allows protocol:// and /local paths where href only allows protocol://
Subject: HTML.pm
package Parse::BBCode::HTML; # %{link}A XSS fix, by N.K.A. use strict; use warnings; use Data::Dumper; use Carp qw(croak carp); use URI::Escape; use base 'Exporter'; our @EXPORT_OK = qw/ &defaults &default_escapes &optional /; our $VERSION = '0.04'; my $email_valid = 0; eval { require Email::Valid; }; $email_valid = 1 unless $@; my %default_tags = ( 'b' => '<b>%s</b>', 'i' => '<i>%s</i>', 'u' => '<u>%s</u>', 'img' => '<img src="%{link}A" alt="[%{html}s]" title="%{html}s">', 'url' => 'url:<a href="%{link}A" rel="nofollow">%s</a>', 'email' => 'url:<a href="mailto:%{email}A">%s</a>', 'size' => '<span style="font-size: %{num}a">%s</span>', 'color' => '<span style="color: %{htmlcolor}a">%s</span>', 'list' => { parse => 1, class => 'block', code => sub { my ($parser, $attr, $content, $attribute_fallback, $tag) = @_; $$content =~ s/^\n+//; $$content =~ s/\n+\z//; return "<ul>$$content</ul>"; }, }, '*' => { parse => 1, code => sub { my ($parser, $attr, $content, $attribute_fallback, $tag) = @_; $$content =~ s/\n+\z//; return "<li>$$content</li>", }, close => 0, class => 'block', }, 'quote' => 'block:<div class="bbcode_quote_header">%{html}a: <div class="bbcode_quote_body">%s</div></div>', 'code' => 'block:<div class="bbcode_code_header">%{html}a: <div class="bbcode_code_body">%{html}s</div></div>', 'noparse' => '%{html}s', ); my %optional_tags = ( 'html' => '%{noescape}s', ); my %default_escapes = ( html => sub { Parse::BBCode::escape_html($_[2]), }, uri => sub { uri_escape($_[2]), }, link => sub { my ($p, $tag, $var) = @_; $var = Parse::BBCode::escape_html($var); $var =~ m{\A\w+://|/}i ? return $var : return ''; }, email => $email_valid ? sub { my ($p, $tag, $var) = @_; # extracts the address part of the email or undef my $valid = Email::Valid->address($var); return $valid ? Parse::BBCode::escape_html($valid) : ''; } : sub { my ($p, $tag, $var) = @_; $var = Parse::BBCode::escape_html($var); }, htmlcolor => sub { $_[2] =~ m/^(?:[a-z]+|#[0-9a-f]{6})\z/ ? $_[2] : 'inherit' }, num => sub { $_[2] =~ m/^[0-9]+\z/ ? $_[2] : 0; }, ); sub defaults { my ($class, @keys) = @_; return @keys ? (map { $_ => $default_tags{$_} } grep { defined $default_tags{$_} } @keys) : %default_tags; } sub default_escapes { my ($class, @keys) = @_; return @keys ? (map { $_ => $default_escapes{$_} } grep { defined $default_escapes{$_} } @keys) : %default_escapes; } sub optional { my ($class, @keys) = @_; return @keys ? (grep defined, @optional_tags{@keys}) : %optional_tags; } 1; __END__ =pod =head1 NAME Parse::BBCode::HTML - Provides HTML defaults for Parse::BBCode =head1 SYNOPSIS use Parse::BBCode; # my $p = Parse::BBCode->new(); my $p = Parse::BBCode->new({ tags => { Parse::BBCode::HTML->defaults, # add your own tags here if needed }, escapes => { Parse::BBCode::HTML->default_escapes, # add your own escapes here if needed }, }); my $code = 'some [b]b code[/b]'; my $parsed = $p->render($code); =head1 METHODS =over 4 =item defaults Returns a hash with default tags. b, i, u, img, url, email, size, color, list, *, quote, code =item default_escapes Returns a hash with escaping functions. These are: html, uri, link, email, htmlcolor, num =item optional Returns a hash of optional tags. These are: html =back =cut