Paranoid(3pm)

Paranoid3pm

Paranoia support for safer programs

Usage

  use Paranoid;
  $errMsg = Paranoid::ERROR;
  psecureEnv("/bin:/usr/bin");
  sub foo {
    # this function can return '0' as a valid return value
    # that should be construed as a boolean true value
    return PTRUE_ZERO;
  }

Version

$Id: lib/Paranoid.pm, 2.10 2022/03/08 00:01:04 acorliss Exp $

Overview

This collection of modules started out as modules which perform things (debatably) in a safer and taint-safe manner. Since then it's also grown to include functionality that fit into the same framework and conventions of the original modules, including keeping the debug hooks for command-line debugging.

All the modules below are intended to be used directly in your programs if you need the functionality they provide.

This module does provide one function meant to secure your environment enough to satisfy taint-enabled programs, and as a container which holds the last reported error from any code in the Paranoid framework.

Import lists

This module exports the following symbols by default:

    psecureEnv

The following specialized import lists also exist:

    List        Members
    --------------------------------------------------------
    all         @defaults PTRUE_ZERO

Subroutines/methods

psecureEnv

  psecureEnv("/bin:/usr/bin");

This function deletes some of the dangerous environment variables that can be used to subvert perl when being run in setuid applications. It also sets the path, either to the passed argument (if passed) or a default of "/bin:/sbin:/usr/bin:/usr/sbin".

NOTE: I did explicitly exclude /usr/local directories from the default path for the following reason: /usr/local is often used by admins to stash random scripts and programs which may not have undergone any serious scrutiny and review for security issues. Only the base OS directories are presumed as safe, and even that may be stretching the truth as it is. You can override the defaults as desired.

Paranoid::ERROR

  $errMsg = Paranoid::ERROR;
  Paranoid::ERROR = $errMsg;

This lvalue function is not exported and must be referenced via the Paranoid namespace.

Ptrue_zero

This is a constant that evaluates to '0 but true', which allows 0 to be passed for boolean true use-cases.

Taint notes

Taint-mode programming can be somewhat of an adventure until you know all the places considered dangerous under perl's taint mode. The following functions should generally have their arguments detainted before using:

  exec        system      open        glob
  unlink      mkdir       chdir       rmdir
  chown       chmod       umask       utime
  link        symlink     kill        eval
  truncate    ioctl       fcntl       chroot
  setpgrp     setpriority syscall     socket
  socketpair  bind        connect

Dependencies

While this module itself doesn't have any external dependencies various child modules do. Please check their documentation for any particulars should you use them.

Bugs and limitations

Releases

8 releases since Debian 6.0 (Squeeze); the text changed 7 times.

  1. 6.0
  2. 7
  3. 8
  4. 9
  5. 10
  6. 11
  7. 12
  8. 13

Author

Arthur Corliss ([email protected])

From libparanoid-perl 2.10-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.