Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
filter.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 May 2011 at 17:21 UTC
Updated:
6 Aug 2012 at 20:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
geek-merlinsee:
http://api.drupal.org/api/drupal/modules--filter--filter.module/function...
Comment #2
catchWould it be better to remove the function_exists() here?
Comment #3
geek-merlinafter some thinking about that, i think so:
a declared but missing callback can and should throw an error.
no need to waste microseconds with error detection here.
Comment #4
catchAnother option is call_user_func() or call_user_func_array() - those throw warnings if callbacks aren't available rather than fatal, however I'm not convinced this is something that should ever get out of sync so that you couldn't recover from it.
check_markup() is cached 99% of the time, and when it's not, what we do in this particular case is not going to have a measurable difference, the filters themselves are usually extremely costly to run.
Comment #5
geek-merlinyou are right.
to me the core point is: we should *never* have unfiltered content when it is supposed to be filtered, so our undefined function should trigger the "loudest" error possible.
("better a wsod that is fixed soon than a unrecognized security issue")
Comment #6
catchHere it is with call_user_func(). This means that if D7 contrib modules or custom code are triggering this, and aren't updated between this getting committed and the next stable release, it'll be a warning instead of 500 when they upgrade.
I'd be OK with just using $function and no function_exists() check in D8, but I'd want to find the original issue that the function_exists() was added first.
Comment #7
geek-merlinpatch looks perfect.
but i have the feeling the other "function_exists" in this file should be addressed the same.
hunted down the commit: hook_filter signature change
http://drupalcode.org/project/drupal.git/commitdiff/2abbabbcc2f8662eb50a...
as of call_user_func i disagree: nonexisting callbacks should never be silently ignored, upgrade pain is better than security or debugging pain, but ymmv.
Comment #8
catchCall user func doesn't silently ignore, it throws a php warning. Looking at the original commit though, these just look like registry function_exists() that gave no purpose whatsoever, so let's remove them and use $function straight.
Comment #9
sunAgreed with #8. Just remove the additional condition, process callbacks are required, and documented as required.
However, I don't see how this is major. Critical/major for a contrib module perhaps, but not for core.
Comment #10
sun#1059884: Drop function_exists for 'callback' functions globally removed most/all function_exists() throughout core for D8.
New code to be ported:
Comment #11
avr commentedBackported for D7.
Comment #12
sunThanks, @avr!
That's sufficient for me. I do not think this needs tests (and, how to test a fatal error in the first place? ;)).
This is a security improvement. But it is also a slight API change in that missing callbacks were silently ignored before, but that's clearly wrong behavior.
Comment #13
David_Rothstein commentedThis is too risky to commit a couple days before 7.15 is released, so I'm leaving it for now... sorry.
I'm also pretty skeptical about committing this to Drupal 7 at all, though. Fatal errors are good if they occur when someone is developing new code (i.e., it definitely makes sense in Drupal 8). But not so good when they suddenly start occurring on live websites...
My vote would be to reconsider some of the earlier ideas in this issue (watchdog messages, PHP warnings that trigger via call_user_func(), etc). That way we still make noise about the error, but don't bring down a website for what in all likelihood is a not-very-serious problem.
Also note that the function_exists() may have been added in D7, but the actual behavior here (silently ignoring a missing process step) goes way back before that (at least to Drupal 5, and probably earlier). Because it used to be done by invoking the module's hook with a 'process' $op, which the module could easily have ignored.
Comment #14
geek-merlini strongly disagree.
if there are still modules out there (which i guess is not the case) whose serious bug (declaring a filter function that does not exist) is protected by this core bug, then having a wsod after upgrade (you test your site after upgrade, don't you?) is better than keeping a security hole (silently ignored filter).
in other terms: protecting security holes by buggy modules which rely on this bug is not an option.
Comment #15
xjmThe branch maintainer says a different approach would be preferred for D7, and I agree this would not be a good thing to backport. It'd be the missing bundle exception all over again. Let's try a different approach?
Edit: also, I checked with a member of the security team and this is not a security issue.