Security Advisories (23)
CVE-2011-2728 (2012-12-21)

The bsd_glob function in the File::Glob module for Perl before 5.14.2 allows context-dependent attackers to cause a denial of service (crash) via a glob expression with the GLOB_ALTDIRFUNC flag, which triggers an uninitialized pointer dereference.

CVE-2020-12723 (2020-06-05)

regcomp.c in Perl before 5.30.3 allows a buffer overflow via a crafted regular expression because of recursive S_study_chunk calls.

CVE-2020-10878 (2020-06-05)

Perl before 5.30.3 has an integer overflow related to mishandling of a "PL_regkind[OP(n)] == NOTHING" situation. A crafted regular expression could lead to malformed bytecode with a possibility of instruction injection.

CVE-2020-10543 (2020-06-05)

Perl before 5.30.3 on 32-bit platforms allows a heap-based buffer overflow because nested regular expression quantifiers have an integer overflow.

CVE-2018-6913 (2018-04-17)

Heap-based buffer overflow in the pack function in Perl before 5.26.2 allows context-dependent attackers to execute arbitrary code via a large item count.

CVE-2018-18314 (2018-12-07)

Perl before 5.26.3 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVE-2018-18313 (2018-12-07)

Perl before 5.26.3 has a buffer over-read via a crafted regular expression that triggers disclosure of sensitive information from process memory.

CVE-2018-18312 (2018-12-05)

Perl before 5.26.3 and 5.28.0 before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVE-2018-18311 (2018-12-07)

Perl before 5.26.3 and 5.28.x before 5.28.1 has a buffer overflow via a crafted regular expression that triggers invalid write operations.

CVE-2015-8853 (2016-05-25)

The (1) S_reghop3, (2) S_reghop4, and (3) S_reghopmaybe3 functions in regexec.c in Perl before 5.24.0 allow context-dependent attackers to cause a denial of service (infinite loop) via crafted utf-8 data, as demonstrated by "a\x80."

CVE-2013-1667 (2013-03-14)

The rehash mechanism in Perl 5.8.2 through 5.16.x allows context-dependent attackers to cause a denial of service (memory consumption and crash) via a crafted hash key.

CVE-2011-0761 (2011-05-13)

Perl 5.10.x allows context-dependent attackers to cause a denial of service (NULL pointer dereference and application crash) by leveraging an ability to inject arguments into a (1) getpeername, (2) readdir, (3) closedir, (4) getsockname, (5) rewinddir, (6) tell, or (7) telldir function call.

CVE-2010-4777 (2014-02-10)

The Perl_reg_numbered_buff_fetch function in Perl 5.10.0, 5.12.0, 5.14.0, and other versions, when running with debugging enabled, allows context-dependent attackers to cause a denial of service (assertion failure and application exit) via crafted input that is not properly handled when using certain regular expressions, as demonstrated by causing SpamAssassin and OCSInventory to crash.

CVE-2009-3626 (2009-10-29)

Perl 5.10.1 allows context-dependent attackers to cause a denial of service (application crash) via a UTF-8 character with a large, invalid codepoint, which is not properly handled during a regular-expression match.

CVE-2012-5195 (2012-12-18)

Heap-based buffer overflow in the Perl_repeatcpy function in util.c in Perl 5.12.x before 5.12.5, 5.14.x before 5.14.3, and 5.15.x before 15.15.5 allows context-dependent attackers to cause a denial of service (memory consumption and crash) or possibly execute arbitrary code via the 'x' string repeat operator.

CVE-2016-2381 (2016-04-08)

Perl might allow context-dependent attackers to bypass the taint protection mechanism in a child process via duplicate environment variables in envp.

CVE-2013-7422 (2015-08-16)

Integer underflow in regcomp.c in Perl before 5.20, as used in Apple OS X before 10.10.5 and other products, allows context-dependent attackers to execute arbitrary code or cause a denial of service (application crash) via a long digit string associated with an invalid backreference within a regular expression.

CVE-2011-1487 (2011-04-11)

The (1) lc, (2) lcfirst, (3) uc, and (4) ucfirst functions in Perl 5.10.x, 5.11.x, and 5.12.x through 5.12.3, and 5.13.x through 5.13.11, do not apply the taint attribute to the return value upon processing tainted input, which might allow context-dependent attackers to bypass the taint protection mechanism via a crafted string.

CVE-2023-47100

In Perl before 5.38.2, S_parse_uniprop_string in regcomp.c can write to unallocated space because a property name associated with a \p{...} regular expression construct is mishandled. The earliest affected version is 5.30.0.

CVE-2024-56406 (2025-04-13)

A heap buffer overflow vulnerability was discovered in Perl. When there are non-ASCII bytes in the left-hand-side of the `tr` operator, `S_do_trans_invmap` can overflow the destination pointer `d`.    $ perl -e '$_ = "\x{FF}" x 1000000; tr/\xFF/\x{100}/;'    Segmentation fault (core dumped) It is believed that this vulnerability can enable Denial of Service and possibly Code Execution attacks on platforms that lack sufficient defenses.

CVE-2023-47039 (2023-10-30)

Perl for Windows relies on the system path environment variable to find the shell (cmd.exe). When running an executable which uses Windows Perl interpreter, Perl attempts to find and execute cmd.exe within the operating system. However, due to path search order issues, Perl initially looks for cmd.exe in the current working directory. An attacker with limited privileges can exploit this behavior by placing cmd.exe in locations with weak permissions, such as C:\ProgramData. By doing so, when an administrator attempts to use this executable from these compromised locations, arbitrary code can be executed.

CVE-2016-1238 (2016-08-02)

(1) cpan/Archive-Tar/bin/ptar, (2) cpan/Archive-Tar/bin/ptardiff, (3) cpan/Archive-Tar/bin/ptargrep, (4) cpan/CPAN/scripts/cpan, (5) cpan/Digest-SHA/shasum, (6) cpan/Encode/bin/enc2xs, (7) cpan/Encode/bin/encguess, (8) cpan/Encode/bin/piconv, (9) cpan/Encode/bin/ucmlint, (10) cpan/Encode/bin/unidump, (11) cpan/ExtUtils-MakeMaker/bin/instmodsh, (12) cpan/IO-Compress/bin/zipdetails, (13) cpan/JSON-PP/bin/json_pp, (14) cpan/Test-Harness/bin/prove, (15) dist/ExtUtils-ParseXS/lib/ExtUtils/xsubpp, (16) dist/Module-CoreList/corelist, (17) ext/Pod-Html/bin/pod2html, (18) utils/c2ph.PL, (19) utils/h2ph.PL, (20) utils/h2xs.PL, (21) utils/libnetcfg.PL, (22) utils/perlbug.PL, (23) utils/perldoc.PL, (24) utils/perlivp.PL, and (25) utils/splain.PL in Perl 5.x before 5.22.3-RC2 and 5.24 before 5.24.1-RC2 do not properly remove . (period) characters from the end of the includes directory array, which might allow local users to gain privileges via a Trojan horse module under the current working directory.

CVE-2015-8608 (2017-02-07)

The VDir::MapPathA and VDir::MapPathW functions in Perl 5.22 allow remote attackers to cause a denial of service (out-of-bounds read) and possibly execute arbitrary code via a crafted (1) drive letter or (2) pInName argument.

NAME

Object::Accessor

SYNOPSIS

### using the object
$obj = Object::Accessor->new;        # create object
$obj = Object::Accessor->new(@list); # create object with accessors
$obj = Object::Accessor->new(\%h);   # create object with accessors
                                     # and their allow handlers

$bool   = $obj->mk_accessors('foo'); # create accessors
$bool   = $obj->mk_accessors(        # create accessors with input
           {foo => ALLOW_HANDLER} ); # validation

$bool   = $obj->mk_aliases(          # create an alias to an existing
            alias_name => 'method'); # method name
            
$clone  = $obj->mk_clone;            # create a clone of original
                                     # object without data
$bool   = $obj->mk_flush;            # clean out all data

@list   = $obj->ls_accessors;        # retrieves a list of all
                                     # accessors for this object

$bar    = $obj->foo('bar');          # set 'foo' to 'bar'
$bar    = $obj->foo();               # retrieve 'bar' again

$sub    = $obj->can('foo');          # retrieve coderef for
                                     # 'foo' accessor
$bar    = $sub->('bar');             # set 'foo' via coderef
$bar    = $sub->();                  # retrieve 'bar' by coderef

### using the object as base class
package My::Class;
use base 'Object::Accessor';

$obj    = My::Class->new;               # create base object
$bool   = $obj->mk_accessors('foo');    # create accessors, etc...

### make all attempted access to non-existant accessors fatal
### (defaults to false)
$Object::Accessor::FATAL = 1;

### enable debugging
$Object::Accessor::DEBUG = 1;

### advanced usage -- callbacks
{   my $obj = Object::Accessor->new('foo');
    $obj->register_callback( sub { ... } );
    
    $obj->foo( 1 ); # these calls invoke the callback you registered
    $obj->foo()     # which allows you to change the get/set 
                    # behaviour and what is returned to the caller.
}        

### advanced usage -- lvalue attributes
{   my $obj = Object::Accessor::Lvalue->new('foo');
    print $obj->foo = 1;            # will print 1
}

### advanced usage -- scoped attribute values
{   my $obj = Object::Accessor->new('foo');
    
    $obj->foo( 1 );
    print $obj->foo;                # will print 1

    ### bind the scope of the value of attribute 'foo'
    ### to the scope of '$x' -- when $x goes out of 
    ### scope, 'foo's previous value will be restored
    {   $obj->foo( 2 => \my $x );
        print $obj->foo, ' ', $x;   # will print '2 2'
    }
    print $obj->foo;                # will print 1
}

DESCRIPTION

Object::Accessor provides an interface to create per object accessors (as opposed to per Class accessors, as, for example, Class::Accessor provides).

You can choose to either subclass this module, and thus using its accessors on your own module, or to store an Object::Accessor object inside your own object, and access the accessors from there. See the SYNOPSIS for examples.

METHODS

$object = Object::Accessor->new( [ARGS] );

Creates a new (and empty) Object::Accessor object. This method is inheritable.

Any arguments given to new are passed straight to mk_accessors.

If you want to be able to assign to your accessors as if they were lvalues, you should create your object in the Object::Acccessor::Lvalue namespace instead. See the section on LVALUE ACCESSORS below.

$bool = $object->mk_accessors( @ACCESSORS | \%ACCESSOR_MAP );

Creates a list of accessors for this object (and NOT for other ones in the same class!). Will not clobber existing data, so if an accessor already exists, requesting to create again is effectively a no-op.

When providing a hashref as argument, rather than a normal list, you can specify a list of key/value pairs of accessors and their respective input validators. The validators can be anything that Params::Check's allow function accepts. Please see its manpage for details.

For example:

$object->mk_accessors( {
    foo     => qr/^\d+$/,       # digits only
    bar     => [0,1],           # booleans
    zot     => \&my_sub         # a custom verification sub
} );        

Returns true on success, false on failure.

Accessors that are called on an object, that do not exist return undef by default, but you can make this a fatal error by setting the global variable $FATAL to true. See the section on GLOBAL VARIABLES for details.

Note that you can bind the values of attributes to a scope. This allows you to temporarily change a value of an attribute, and have it's original value restored up on the end of it's bound variable's scope;

For example, in this snippet of code, the attribute foo will temporarily be set to 2, until the end of the scope of $x, at which point the original value of 1 will be restored.

my $obj = Object::Accessor->new;

$obj->mk_accessors('foo');
$obj->foo( 1 );
print $obj->foo;                # will print 1

### bind the scope of the value of attribute 'foo'
### to the scope of '$x' -- when $x goes out of 
### scope, 'foo' previous value will be restored
{   $obj->foo( 2 => \my $x );
    print $obj->foo, ' ', $x;   # will print '2 2'
}
print $obj->foo;                # will print 1

Note that all accessors are read/write for everyone. See the TODO section for details.

@list = $self->ls_accessors;

Returns a list of accessors that are supported by the current object. The corresponding coderefs can be retrieved by passing this list one by one to the can method.

$ref = $self->ls_allow(KEY)

Returns the allow handler for the given key, which can be used with Params::Check's allow() handler. If there was no allow handler specified, an allow handler that always returns true will be returned.

$bool = $self->mk_aliases( alias => method, [alias2 => method2, ...] );

Creates an alias for a given method name. For all intents and purposes, these two accessors are now identical for this object. This is akin to doing the following on the symbol table level:

*alias = *method

This allows you to do the following:

$self->mk_accessors('foo');
$self->mk_aliases( bar => 'foo' );

$self->bar( 42 );
print $self->foo;     # will print 42

$clone = $self->mk_clone;

Makes a clone of the current object, which will have the exact same accessors as the current object, but without the data stored in them.

$bool = $self->mk_flush;

Flushes all the data from the current object; all accessors will be set back to their default state of undef.

Returns true on success and false on failure.

$bool = $self->mk_verify;

Checks if all values in the current object are in accordance with their own allow handler. Specifically useful to check if an empty initialised object has been filled with values satisfying their own allow criteria.

$bool = $self->register_callback( sub { ... } );

This method allows you to register a callback, that is invoked every time an accessor is called. This allows you to munge input data, access external data stores, etc.

You are free to return whatever you wish. On a set call, the data is even stored in the object.

Below is an example of the use of a callback.

$object->some_method( "some_value" );

my $callback = sub {
    my $self    = shift; # the object
    my $meth    = shift; # "some_method"
    my $val     = shift; # ["some_value"]  
                         # could be undef -- check 'exists';
                         # if scalar @$val is empty, it was a 'get'

    # your code here

    return $new_val;     # the value you want to be set/returned
}        

To access the values stored in the object, circumventing the callback structure, you should use the ___get and ___set methods documented further down.

$bool = $self->can( METHOD_NAME )

This method overrides UNIVERAL::can in order to provide coderefs to accessors which are loaded on demand. It will behave just like UNIVERSAL::can where it can -- returning a class method if it exists, or a closure pointing to a valid accessor of this particular object.

You can use it as follows:

$sub = $object->can('some_accessor');   # retrieve the coderef
$sub->('foo');                          # 'some_accessor' now set
                                        # to 'foo' for $object
$foo = $sub->();                        # retrieve the contents
                                        # of 'some_accessor'

See the SYNOPSIS for more examples.

$val = $self->___get( METHOD_NAME );

Method to directly access the value of the given accessor in the object. It circumvents all calls to allow checks, callbakcs, etc.

Use only if you Know What You Are Doing! General usage for this functionality would be in your own custom callbacks.

$bool = $self->___set( METHOD_NAME => VALUE );

Method to directly set the value of the given accessor in the object. It circumvents all calls to allow checks, callbakcs, etc.

Use only if you Know What You Are Doing! General usage for this functionality would be in your own custom callbacks.

$bool = $self->___alias( ALIAS => METHOD );

Method to directly alias one accessor to another for this object. It circumvents all sanity checks, etc.

Use only if you Know What You Are Doing!

LVALUE ACCESSORS

Object::Accessor supports lvalue attributes as well. To enable these, you should create your objects in the designated namespace, Object::Accessor::Lvalue. For example:

my $obj = Object::Accessor::Lvalue->new('foo');
$obj->foo += 1;
print $obj->foo;

will actually print 1 and work as expected. Since this is an optional feature, that's not desirable in all cases, we require you to explicitly use the Object::Accessor::Lvalue class.

Doing the same on the standard Object>Accessor> class would generate the following code & errors:

my $obj = Object::Accessor->new('foo');
$obj->foo += 1;

Can't modify non-lvalue subroutine call

Note that lvalue support on AUTOLOAD routines is a perl 5.8.x feature. See perldoc perl58delta for details.

CAVEATS

  • Allow handlers

    Due to the nature of lvalue subs, we never get access to the value you are assigning, so we can not check it againt your allow handler. Allow handlers are therefor unsupported under lvalue conditions.

    See perldoc perlsub for details.

  • Callbacks

    Due to the nature of lvalue subs, we never get access to the value you are assigning, so we can not check provide this value to your callback. Furthermore, we can not distinguish between a get and a set call. Callbacks are therefor unsupported under lvalue conditions.

    See perldoc perlsub for details.

GLOBAL VARIABLES

$Object::Accessor::FATAL

Set this variable to true to make all attempted access to non-existant accessors be fatal. This defaults to false.

$Object::Accessor::DEBUG

Set this variable to enable debugging output. This defaults to false.

TODO

Create read-only accessors

Currently all accessors are read/write for everyone. Perhaps a future release should make it possible to have read-only accessors as well.

CAVEATS

If you use codereferences for your allow handlers, you will not be able to freeze the data structures using Storable.

Due to a bug in storable (until at least version 2.15), qr// compiled regexes also don't de-serialize properly. Although this bug has been reported, you should be aware of this issue when serializing your objects.

You can track the bug here:

http://rt.cpan.org/Ticket/Display.html?id=1827

BUG REPORTS

Please report bugs or other issues to <bug-object-accessor@rt.cpan.org>.

AUTHOR

This module by Jos Boumans <kane@cpan.org>.

COPYRIGHT

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