in reply to Re^4: How to disable taint checking by Perl?
in thread How to disable taint checking by Perl?

Corion,

It has been my understanding that the taint mode was not explicitly turned on as well--until I encountered issues not long back with a more recent version of Perl, leading to my present uncertainty. Can you verify that the current Perl version does not automatically use taint, without it having been explicitly invoked in the script, and are you aware of any online documentation for this?

Blessings,

~Polyglot~

  • Comment on Re^5: How to disable taint checking by Perl?

Replies are listed 'Best First'.
Re^6: How to disable taint checking by Perl?
by Corion (Patriarch) on Oct 25, 2023 at 13:47 UTC

    I don't know why the absence of an idea would be explicitly documented somewhere in the Perl documentation. But you can look through the past perldelta files, which would certainly list that change.

    A quick test that Perl does not enable taint mode by default:

    corion$ perl -MScalar::Util=tainted -wE 'my $fn = shift; say tainted($ +fn)' foo 0 corion$ perl -T -MScalar::Util=tainted -wE 'my $fn = shift; say tainte +d($fn)' foo 1
      What version of Perl is that, Corion?

      The link you shared earlier stated:

      By default, Perl automatically enables a set of special security checks, called taint mode, when it detects its program running with differing real and effective user or group IDs.

      But, lest one think that this were the only criterion upon which taint would be invoked, look a little further down in that documentation and we see...

      Support for taint checks adds an overhead to all Perl programs, whether or not you're using the taint features. Perl 5.18 introduced C preprocessor symbols that can be used to disable the taint features.
      ...and this is followed by some itemization of things that are not checked by default for taintedness, implying everything else is.

      To my logical mind, those two statements don't quite add up. Why does taint need to have special ways of being disabled if it were not first engaged? If taint checks can be done on an explicit, variable basis, why the need to have special tools to disengage it?

      Thus, I find the documentation to be ambiguous. Perhaps someone could help to rewrite that portion of the documentation to make clear exactly how much taint checking is made mandatory, and by which versions of Perl. A table would be nice. I like tables.

      Blessings,

      ~Polyglot~

        A table would be nice. I like tables.

        Here is a table showing when taint mode is enabled. HTH.

        Perl versionUID != EUIDGID != EGID-T argumentAnything else
        5.10.0YesYesYesNo
        5.12.0YesYesYesNo
        5.14.0YesYesYesNo
        5.16.0YesYesYesNo
        5.18.0YesYesYesNo
        5.20.0YesYesYesNo
        5.22.0YesYesYesNo
        5.24.0YesYesYesNo
        5.26.0YesYesYesNo
        5.28.0YesYesYesNo
        5.30.0YesYesYesNo
        5.32.0YesYesYesNo
        5.34.0YesYesYesNo
        5.36.0YesYesYesNo
        5.38.0YesYesYesNo

        🦛

        Changes in the C preprocessor symbols affects how Perl is compiled. If you don't compile Perl yourself using these special symbols, your perl executable supports taint checks.

        The items in the documentation are not related to the paragraph about the C preprocessor symbols. These things are never tainted/checked for taintedness.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

        I see that when the paragraph about preprocessor symbols was added, it was placed between the phrase with the following exceptions: and the list of exceptions. I have submitted a patch to fix that (here), but in the meantime the document may make a little more sense if you temporarily cover up the paragraph starting "Support for taint checks adds an overhead to all Perl programs".

Re^6: How to disable taint checking by Perl?
by marto (Cardinal) on Oct 25, 2023 at 13:47 UTC
    The explanation in the first paragraph is explicitly defined in the hyperlink provided. Previously.