Security Advisories (10)
CVE-2021-47157 (2021-08-29)

Flaw in defense from JSON hijacking.

CVE-2020-11022 (2020-04-29)

In jQuery versions greater than or equal to 1.2 and before 3.5.0, passing HTML from untrusted sources - even after sanitizing it - to one of jQuery's DOM manipulation methods (i.e. .html(), .append(), and others) may execute untrusted code. This problem is patched in jQuery 3.5.0.

CVE-2020-11023 (2020-04-29)

In jQuery versions greater than or equal to 1.0.3 and before 3.5.0, passing HTML containing <option> elements from untrusted sources - even after sanitizing it - to one of jQuery's DOM manipulation methods (i.e. .html(), .append(), and others) may execute untrusted code. This problem is patched in jQuery 3.5.0.

CVE-2019-11358 (2019-04-20)

jQuery before 3.4.0, as used in Drupal, Backdrop CMS, and other products, mishandles jQuery.extend(true, {}, ...) because of Object.prototype pollution. If an unsanitized source object contained an enumerable __proto__ property, it could extend the native Object.prototype.

CVE-2015-9251 (2018-01-18)

jQuery before 3.0.0 is vulnerable to Cross-site Scripting (XSS) attacks when a cross-domain Ajax request is performed without the dataType option, causing text/javascript responses to be executed.

CVE-2011-4969 (2013-03-08)

Cross-site scripting (XSS) vulnerability in jQuery before 1.6.3, when using location.hash to select elements, allows remote attackers to inject arbitrary web script or HTML via a crafted tag.

CVE-2012-6708 (2018-01-18)

jQuery before 1.9.0 is vulnerable to Cross-site Scripting (XSS) attacks. The jQuery(strInput) function does not differentiate selectors from HTML in a reliable fashion. In vulnerable versions, jQuery determined whether the input was HTML by looking for the '<' character anywhere in the string, giving attackers more flexibility when attempting to construct a malicious payload. In fixed versions, jQuery only deems the input to be HTML if it explicitly starts with the '<' character, limiting exploitability only to attackers who can control the beginning of a string, which is far less common.

CVE-2020-7656 (2020-05-19)

jquery prior to 1.9.0 allows Cross-site Scripting attacks via the load method. The load method fails to recognize and remove "<script>" HTML tags that contain a whitespace character, i.e: "</script >", which results in the enclosed script logic to be executed.

CVE-2019-5428

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as _proto_, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

CVE-2014-6071 (2018-01-16)

jQuery 1.4.2 allows remote attackers to conduct cross-site scripting (XSS) attacks via vectors related to use of the text method inside after.

NAME

Kossy - Sinatra-ish Simple and Clear web application framework

SYNOPSIS

% kossy-setup MyApp
% cd MyApp
% plackup app.psgi

## lib/MyApp/Web.pm

use Kossy;

get '/' => sub {
    my ( $self, $c )  = @_;
    $c->render('index.tx', { greeting => "Hello!" });
};

get '/json' => sub {
    my ( $self, $c )  = @_;
    my $result = $c->req->validator([
        'q' => {
            default => 'Hello',
            rule => [
                [['CHOICE',qw/Hello Bye/],'Hello or Bye']
            ],
        }
    ]);
    $c->render_json({ greeting => $result->valid->get('q') });
};

1;

## views/index.tx
: cascade base
: around content -> {
  <: $greeting :>
: }

DESCRIPTION

Kossy is Sinatra-ish Simple and Clear web application framework, which is based upon Plack, Router::Simple, Text::Xslate and build-in Form-Validator. That's suitable for small application and rapid development.

Kossy class

Kossy exports some methods to building application

CLASS METHODS for Kossy class

my $kossy = Kossy->new( root_dir => $root_dir );

Create instance of the application object.

OBJECT METHODS for Kossy class

my $root_dir = $kossy->root_dir();

accessor to root directory of the application

my $app = $kossy->psgi();

return PSGI application

DISPATCHER METHODS for Kossy class

filter

makes application wrapper like plack::middlewares.

filter 'set_title' => sub {
    my $app:CODE = shift;
    sub {
        my ( $self:Kossy, $c:Kossy::Connection )  = @_;
        $c->stash->{site_name} = __PACKAGE__;
        $app->($self,$c);
    }
};
get path:String => [[filters] =>] CODE
post path:String => [[filters] =>] CODE

setup router and dispatch code

get '/' => [qw/set_title/] => sub {
    my ( $self:Kossy, $c:Kossy::Connection )  = @_;
    $c->render('index.tx', { greeting => "Hello!" });
};

get '/json' => sub {
    my ( $self:Kossy, $c:Kossy::Connection )  = @_;
    $c->render_json({ greeting => "Hello!" });
};

dispatch code shall return Kossy::Response object or PSGI response ArrayRef or String.

router 'HTTP_METHOD'|['METHOD'[,'METHOD']] => path:String => [[filters] =>] CODE

adds routing rule other than GET and POST

router 'PUT' => '/put' => sub {
    my ( $self:Kossy, $c:Kossy::Connection )  = @_;
    $c->render_json({ greeting => "Hello!" });
};

Kossy::Connection class

per-request object, herds request and response

OBJECT METHODS for Kossy::Connection class

req:Kossy::Request
res:Kossy::Response
stash:HashRef
args:HashRef

Router::Simple->match result

halt(status_code, message)

die and response immediately

redirect($uri,status_code): Kossy::Response
render($file,$args): Kossy::Response

calls Text::Xslate->render makes response. template files are searching in root_dir/views directory

template syntax is Text::Xslate::Syntax::Kolon, can use Kossy::Connection object and fillinform block.

## template.tx
: block form |  fillinform( $c.req ) -> {
<head>
<title><: $c.stash.title :></title>
</head>
<body>
<form action="<: $c.req.uri_for('/post') :>">
<input type="text" size="10" name="title" />
<textarea name="body" rows="20" cols="90"></textarea>
</form>
</body>
: }

also can use Text::Xslate::Bridge::TT2Like and Number::Format methods in your template

render_json($args): Kossy::Response

serializes arguments with JSON and makes response

This method escapes '<', '>', and '+' characters by "\uXXXX" form. Browser don't detects the JSON as HTML. And also this module outputs "X-Content-Type-Options: nosniff" header for IEs.

render_json have a JSON hijacking detection feature same as Amon2::Plugin::Web::JSON. This returns "403 Forbidden" response if following pattern request.

The request have 'Cookie' header.
The request doesn't have 'X-Requested-With' header.
The request contains /android/i string in 'User-Agent' header.
Request method is 'GET'

Kossy::Request

This class is child class of Plack::Request, decode query/body parameters automatically. Return value of $req->param(), $req->body_parameters, etc. is the decoded value.

OBJECT METHODS for Kossy::Request class

uri_for($path,$args):String

build absolute URI with path and $args

my $uri = $c->req->uri_for('/login',[ arg => 'Hello']);  
validator($rule):Kossy::Validaor::Result

validate parameters using Kossy::Validatar

my $result = $c->req->validator([
  'q' => [['NOT_NULL','query must be defined']],
  'level' => {
      default => 'M',
      rule => [
          [['CHOICE',qw/L M Q H/],'invalid level char'],
      ],
  },
]);

my $val = $result->valid('q');
my $val = $result->valid('level');
body_parameters_raw
query_parameters_raw
parameters_raw
param_raw

These methods are the accessor to raw values. 'raw' means the value is not decoded.

Kossy::Response

This class is child class of Plack::Response

AUTHOR

Masahiro Nagano <kazeburo {at} gmail.com>

SEE ALSO

Kossy is small waf, that has only 400 lines code. so easy to reading framework code and customize it. Sinatra-ish router, build-in templating, validators and zero-configuration features are suitable for small application and rapid development.

Amon2::Lite

Mojolicious::Lite

Dancer

Kossy::Validator

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.