Skip to content

Remove the AUTOLOAD method from contextExtensions.pl. - #1564

Open
drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:context-extensions-no-autoload
Open

drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:context-extensions-no-autoload

Conversation

@drgrice1

Copy link
Copy Markdown
Member

This method was only needed for a context that extends the SignificantFigures context (for example the Units context via context::Units::extending('SignificantFigures')) because the contextSignificantFigures.pl macro calls the methods of its context::SignificantFigures::common package as $self->STRING, $self->COPY, etc. When another context extends the SignificantFigures context, those calls are made with $self blessed into the extension context's classes, and those classes do not inherit from that package. So those methods were not found, and the AUTOLOAD method was used to find them in the extended class. Instead the contextSignificantFigures.pl macro now calls those methods with their fully qualified names, so that they are found regardless of the class of $self.

The updated WWSafe.pm module based on Safe.pm version 2.47 (added in #1520) deletes the AUTOLOAD method (as well as the DELETE method and any overloads) in its _clean_stash call, and so the current AUTOLOAD method no longer works, and problems using the Units context extending the SignificantFigures context were broken.

Allowing code that runs in the safe compartment to define a DESTROY or AUTOLOAD method or to defined custom overloads is a security vulnerability that cannot be allowed.

This method was only needed for a context that extends the
SignificantFigures context (for example the Units context via
`context::Units::extending('SignificantFigures')`) because the
`contextSignificantFigures.pl` macro calls the methods of its
`context::SignificantFigures::common` package as `$self->STRING`,
`$self->COPY`, etc.  When another context extends the SignificantFigures
context, those calls are made with `$self` blessed into the extension
context's classes, and those classes do not inherit from that package.
So those methods were not found, and the `AUTOLOAD` method was used to
find them in the extended class.  Instead the `contextSignificantFigures.pl`
macro now calls those methods with their fully qualified names, so that
they are found regardless of the class of `$self`.

The updated `WWSafe.pm` module based on `Safe.pm` version 2.47 (added in
openwebwork#1520) deletes the `AUTOLOAD` method (as well as the `DELETE` method and
any overloads) in its `_clean_stash` call, and so the current `AUTOLOAD`
method no longer works, and problems using the Units context extending
the SignificantFigures context were broken.

Allowing code that runs in the safe compartment to define a `DESTROY` or
`AUTOLOAD` method or to defined custom overloads is a security
vulnerability that cannot be allowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@drgrice1
drgrice1 force-pushed the context-extensions-no-autoload branch from 980577a to bc9523c Compare October 27, 2026 21:12

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant