If we add an extra arg to rss.xml - e.g. ?q=rss.xml/a, we get big flaming errors:

# Warning: array_flip(): The argument should be an array in DrupalDefaultEntityController->load() (line 109 of /drupal-7/includes/entity.inc).
# Warning: Invalid argument supplied for foreach() in DatabaseCondition->compile() (line 1271 of /drupal-7/includes/database/query.inc).
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 2: SELECT revision.timestamp AS revision_timestamp, revision.uid AS revision_uid, revision.vid AS vid, revision.title AS title, revision.log AS log, revision.status AS status, revision.comment AS comment, revision.promote AS promote, revision.sticky AS sticky, base.nid AS nid, base.type AS type, base.language AS language, base.uid AS uid, base.created AS created, base.changed AS changed, base.tnid AS tnid, base.translate AS translate FROM {node} base INNER JOIN {node_revision} revision ON revision.vid = base.vid WHERE (base.nid IN ()) ; Array ( )  in DrupalDefaultEntityController->load() (line 127 of /drupal-7/includes/entity.inc).

and no output.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Status: Active » Closed (won't fix)

garbage in, garbage out. That's just good.

pwolanin’s picture

Status: Closed (won't fix) » Active

I disagree - user input triggering a SQL error is a form of SQL injection

Dave Reid’s picture

Status: Active » Needs review
FileSize
2.42 KB
voxpelli’s picture

Priority: Critical » Normal
FileSize
477 bytes

An alternate patch to Dave Reids - should we really return anything but a 404 for a subpath to rss.xml?

Also - can't see why this is a critical issue - no SQL injection possible.

pwolanin’s picture

Many places in Drupal extra path parts are just ignored - I'd expect that instead of a 404.

Here's the no-WS change version of Dave's patch plus regression tests.

webchick’s picture

Can someone explain why we need to fix this this way when we don't have to add those weird page arguments to any other menu callback? Should we not address this in node_feed()?

pwolanin’s picture

@webchick - the issue is that we are using an API function directly as the page callback without wrapping it - so we are essentially just provding correct/safe arguments rather than allowing the menu system to pass in arbitrary arguments. The alternative is to do more parameter checking in node_feed, but this seems simpler.

A couple other existing examples from core:

  $items['system/files'] = array(
    'title' => 'File download',
    'page callback' => 'file_download',
    'page arguments' => array('private'),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['admin/config/search/clean-urls/check'] = array(
    'title' => 'Clean URL check',
    'page callback' => 'drupal_json_output',
    'page arguments' => array(array('status' => TRUE)),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'system.admin.inc',
  );
webchick’s picture

Hm. I think my preference would actually be for a "buffer" function between the two (node_feed_page?). That array(FALSE, array()) thing seems pretty weird.

pwolanin’s picture

@webchick - well, that array(FALSE, array()) is just doing exactly what the wrapper function would do....

ksenzee’s picture

If we add a wrapper function, we can at least document the array(FALSE, array()) thing.

MichaelCole’s picture

#5: 622426-node-rss-errors-5t.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 622426-node-rss-errors-5t.patch, failed testing.

mr.baileys’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs work » Needs review
FileSize
1.96 KB
1.58 KB

Re-rolled against HEAD. I think adding a wrapper function for this is overkill.

If we add a wrapper function, we can at least document the array(FALSE, array()) thing.

Well, we might just as well document the array(FALSE, array()) in node_menu, we don't need to add a function just for documentation purposes.

2 patches attached:

  • option A: pwolanin's patch with an additional doc line.
  • option B: alternate patch that introduces parameter checking in the API layer.
drbeaker’s picture

I've tried both of these patches and still get the issue. Any ideas?

mr.baileys’s picture

@drbeaker: did you rebuild the menu after applying the patches? (Administer > Configuration > Performance > Clear All Caches should do the trick).

greggles’s picture

I disagree - user input triggering a SQL error is a form of SQL injection

I don't know it's a form of "sql injection" but it is often flagged as such by automated scanners.

It's just an error, imo, and certainly one worth fixing.

Dave Reid’s picture

Status: Needs review » Needs work

Reviewing the option A patch as that's the one I prefer. People should always be in the habit of providing default parameters in their menu callbacks.

+++ b/modules/node/node.testundefined
@@ -813,6 +813,16 @@ class NodeRSSContentTestCase extends DrupalWebTestCase {
+    // Regression test for #622426.  Extra path parts should be ignored.
+    $this->drupalGet('rss.xml/a');
+    // Check that content added in 'rss' build mode appear in RSS feed.
+    $rss_only_content = t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->nid));
+    $this->assertText($rss_only_content, t('Node content designated for RSS appear in RSS feed.'));
+    $this->drupalGet('rss.xml/b/c');
+
+    // Check that content added in 'rss' build mode appear in RSS feed.
+    $rss_only_content = t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->nid));
+    $this->assertText($rss_only_content, t('Node content designated for RSS appear in RSS feed.'));
   }

I don't see why we are redeclaring $rss_only_content twice again when it is already defined earlier in the test and doesn't need to be changed.

We could probably simplify this by just doing $this->drupalGet('rss.xml/a/b'). Doing so tests $this->drupalGet('rss.xml/a') as well.

"Check that content added in 'rss' build mode appearappears in RSS feed."

xjm’s picture

Status: Needs work » Closed (duplicate)