Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] ActiveSupport::Multibyte.clean is very slow

#3181

The addition of a call to ActiveSupport::Multibyte#clean in ActionView::Helpers::TagHelper.escape_once in the recent security patch and 2.4.3 (9a68c72b4 and its parent) has led to a substantial increase in CPU usage on our servers.

Running each specified through a valid-character regexp is obviously expensive, but the patch can be improved somewhat by making a small tweak to ActiveSupport::Multibyte#clean and ActiveSupport::Multibyte#verify.

For 10000 runs on a 90 character string on my MacBook Pro:

                          user     system      total        real
clean-orig            9.760000   2.220000  11.980000 ( 12.030811)
clean-patched         6.230000   1.480000   7.710000 (  7.734848)

                      user     system      total        real



verify-orig 9.360000 2.240000 11.600000 ( 11.697971) verify-patched 5.970000 1.510000 7.480000 ( 7.529034)

I've attached the patch, tests pass.

Reported by Beau Harrington · September 10th, 2009 @ 06:32 AM

State: committed
Milestone: none
Assigned to: Michael Koziarski Michael Koziarski
Importance: none

Activity

  1. Grant Hutchins
    Grant Hutchins

    We ran into the same CPU usage spikes when we applied 2-2-CVE-2009-3009.patch to our Rails 2.2.2 gems.

    Our production servers essentially became unusable and we had to roll back to the pristine 2.2.2 gems.

    In internal testing, the additional CPU load is almost entirely removed by applying this patch.

    September 10th, 2009 @ 11:50 PM

  2. Grant Hutchins
    Grant Hutchins
    • Assigned user set to Michael Koziarski

    September 11th, 2009 @ 12:04 AM

  3. Repository
    Repository
    • State changed from new to committed

    (from [b4a0d1b21bca69635e43601e721122bb84a9197e]) Remove redundant checks for valid character regexp in ActiveSupport::Multibyte#clean and #verify.

    [#3181 [PATCH] ActiveSupport::Multibyte.clean is very slow state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/b4a0d1b21bca69635e43601e721122...

    September 11th, 2009 @ 02:11 AM

  4. Repository
    Repository

    (from [095cf9135b3ae2e3f88effec9a47e4ae30a71940]) Remove redundant checks for valid character regexp in ActiveSupport::Multibyte#clean and #verify.

    [#3181 [PATCH] ActiveSupport::Multibyte.clean is very slow state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/095cf9135b3ae2e3f88effec9a47e4...

    September 11th, 2009 @ 02:11 AM

  5. Repository
    Repository

    (from [a32eeebdcbf56f433e5a7410c0f235812c9fee00]) Remove redundant checks for valid character regexp in ActiveSupport::Multibyte#clean and #verify.

    [#3181 [PATCH] ActiveSupport::Multibyte.clean is very slow state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/a32eeebdcbf56f433e5a7410c0f235...

    September 11th, 2009 @ 02:11 AM

  6. Repository
    Repository

    (from [81d828a14c82b882e31612431a56f830bdc1076f]) Remove redundant checks for valid character regexp in ActiveSupport::Multibyte#clean and #verify.

    [#3181 [PATCH] ActiveSupport::Multibyte.clean is very slow state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/81d828a14c82b882e31612431a56f8...

    September 11th, 2009 @ 02:11 AM

  7. Repository
    Repository

    (from [38d65b03d6634b6993427213933aaa413a20c415]) Remove redundant checks for valid character regexp in ActiveSupport::Multibyte#clean and #verify.

    [#3181 [PATCH] ActiveSupport::Multibyte.clean is very slow state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/38d65b03d6634b6993427213933aaa...

    September 11th, 2009 @ 02:11 AM