Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1366479 - CVE-2016-6317 rubygem-activerecord: unsafe query generation in Active Record [fedora-all]
Summary: CVE-2016-6317 rubygem-activerecord: unsafe query generation in Active Record ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: rubygem-activerecord
Version: 24
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jun Aruga
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-12 05:59 UTC by Martin Prpič
Modified: 2016-08-29 21:21 UTC (History)
8 users (show)

Fixed In Version: rubygem-rails-5.0.0.1-1.fc25 rubygem-rails-5.0.0.1-1.fc26 rubygem-activerecord-5.0.0.1-1.fc25 rubygem-activerecord-4.2.5.2-2.fc24 rubygem-activerecord-4.2.3-3.fc23
Doc Type: Release Note
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-08-27 10:26:00 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
f24 - activerecord - Fix for CVE-2016-6317 (8.11 KB, patch)
2016-08-17 18:20 UTC, Jun Aruga
no flags Details | Diff
f24 - activerecord - Fix for CVE-2016-6317 #2 (8.22 KB, patch)
2016-08-17 18:28 UTC, Jun Aruga
no flags Details | Diff
f24 - actionpack - Fix for CVE-2016-6317 (3.75 KB, patch)
2016-08-18 10:52 UTC, Jun Aruga
no flags Details | Diff
f24 - Tests enhancement (2.05 KB, patch)
2016-08-18 17:30 UTC, Pavel Valena
no flags Details | Diff
f24 - activerecord - Fix for CVE-2016-6317 #3 (8.15 KB, patch)
2016-08-19 11:22 UTC, Jun Aruga
no flags Details | Diff
f24 - activerecord - Fix for CVE-2016-6317 #4 (8.15 KB, patch)
2016-08-19 13:34 UTC, Jun Aruga
no flags Details | Diff
f23 - activerecord - Fix for CVE-2016-6317 (4.98 KB, patch)
2016-08-19 13:38 UTC, Jun Aruga
no flags Details | Diff
f23 - actionpack - Fix for CVE-2016-6317 (3.83 KB, patch)
2016-08-19 14:11 UTC, Jun Aruga
no flags Details | Diff

Description Martin Prpič 2016-08-12 05:59:55 UTC
This is an automatically created tracking bug!  It was created to ensure
that one or more security vulnerabilities are fixed in affected versions
of Fedora.

For comments that are specific to the vulnerability please use bugs filed
against the "Security Response" product referenced in the "Blocks" field.

For more information see:
http://fedoraproject.org/wiki/Security/TrackingBugs

When submitting as an update, use the fedpkg template provided in the next
comment(s).  This will include the bug IDs of this tracking bug as well as
the relevant top-level CVE bugs.

Please also mention the CVE IDs being fixed in the RPM changelog and the
fedpkg commit message.

NOTE: this issue affects multiple supported versions of Fedora. While only
one tracking bug has been filed, please correct all affected versions at
the same time.  If you need to fix the versions independent of each other,
you may clone this bug as appropriate.

[bug automatically created by: add-tracking-bugs]

Comment 1 Martin Prpič 2016-08-12 06:00:03 UTC
Use the following template to for the 'fedpkg update' request to submit an
update for this issue as it contains the top-level parent bug(s) as well as
this tracking bug.  This will ensure that all associated bugs get updated
when new packages are pushed to stable.

=====

# bugfix, security, enhancement, newpackage (required)
type=security

# testing, stable
request=testing

# Bug numbers: 1234,9876
bugs=1365017,1366479

# Description of your update
notes=Security fix for CVE-2016-6317

# Enable request automation based on the stable/unstable karma thresholds
autokarma=True
stable_karma=3
unstable_karma=-3

# Automatically close bugs when this marked as stable
close_bugs=True

# Suggest that users restart after update
suggest_reboot=False

======

Additionally, you may opt to use the bodhi web interface to submit updates:

https://bodhi.fedoraproject.org/updates/new

Comment 2 Jun Aruga 2016-08-16 10:10:11 UTC
I will do it for F24 and F23.

Comment 3 Jun Aruga 2016-08-16 13:46:50 UTC
Target commit hash is here.
https://bugzilla.redhat.com/show_bug.cgi?id=1365017#c6

Comment 4 Jun Aruga 2016-08-16 16:52:05 UTC
I found bugs in current F24 latest build for rubygem-activerecord.

https://kojipkgs.fedoraproject.org//packages/rubygem-activerecord/4.2.5.2/1.fc24/data/logs/noarch/build.log

```
+ ruby -I.:test:lib
+ egrep '(1|2|3|4|5) failures'
sh: sqlite3: command not found
sh: sqlite3: command not found
4298 runs, 10894 assertions, 11 failures, 236 errors, 2 skips
~/build/BUILD/activerecord-4.2.5.2
+ popd
+ exit 0
```

Below line with pipe does not handle the ruby test error. It is success with "11 failures".


```
ruby -I.:test:lib <<EOF | egrep "(1|2|3|4|5) failures"
```


```
$ ls xyz | echo xyz
xyz
ls: cannot access xyz: No such file or directory
$ echo $?
0
```

Also sqlite3 is not installed for some reason.

rubygem-activerecord depends on rubygem-sqlite3
rubygem-sqlite3 depends on sqlite-devel
However I can not find sqlite-devel in PkgDB.

Comment 5 Pavel Valena 2016-08-16 17:32:35 UTC
Yes, Jun, you are right. the sqlite3 BuildRequire is missing there[1].

Also, the grep is broken, it should be something simmilar to:

```
ruby -I.:test:lib <<EOF | egrep ", (1|2|3|4|5) failures, "
```

to avoid grepping any number which ends with 1-5.

> rubygem-sqlite3 depends on sqlite-devel
This not relevant, as it is a BuildRequire.


[1] http://pkgs.fedoraproject.org/cgit/rpms/rubygem-activerecord.git/tree/rubygem-activerecord.spec?h=f24&id=cc94d5714ddb97aba9b3468ae6f519107cef4277

Comment 6 Jun Aruga 2016-08-16 17:44:27 UTC
Thank you for your checking!

(In reply to Pavel Valena from comment #5)
> Yes, Jun, you are right. the sqlite3 BuildRequire is missing there[1].
> 
> Also, the grep is broken, it should be something simmilar to:
> 
> ```
> ruby -I.:test:lib <<EOF | egrep ", (1|2|3|4|5) failures, "
> ```
> 
> to avoid grepping any number which ends with 1-5.

I want to change the logic to succeed with 1-5 failure like f25, master(rawhide), to comment out unstable unit test.
Because we are going to add additional a few unit tests for this ticket's security issue. However above logic can not guarantee the success.

> > rubygem-sqlite3 depends on sqlite-devel
> This not relevant, as it is a BuildRequire.

Sorry, it is not relevant, as you said.

> 
> 
> [1]
> http://pkgs.fedoraproject.org/cgit/rpms/rubygem-activerecord.git/tree/
> rubygem-activerecord.spec?h=f24&id=cc94d5714ddb97aba9b3468ae6f519107cef4277

Comment 7 Jun Aruga 2016-08-16 17:47:46 UTC
> I want to change the logic to succeed with 1-5 failure like f25, master(rawhide), to comment out unstable unit test.

Above my English is not correct.

I want to change the test grep logic allowing 1-5 failure,
to comment out unstable unit test with 1-5 failure like f25, master(rawhide).

Comment 8 Pavel Valena 2016-08-16 18:22:34 UTC
> > Also, the grep is broken, it should be something simmilar to:
> > 
> > ```
> > ruby -I.:test:lib <<EOF | egrep ", (1|2|3|4|5) failures, "
> > ```
> > 
> > to avoid grepping any number which ends with 1-5.
> 
> I want to change the logic to succeed with 1-5 failure like f25,
> master(rawhide), to comment out unstable unit test.
> Because we are going to add additional a few unit tests for this ticket's
> security issue. However above logic can not guarantee the success.
> 

As a matter of fact, it can. The grep I posted matches exactly 1-5 errors, and therefore, in case of 11 errors it fails. The previous one, in git, however succeeds. That is because the grep did not check for the whole failed tests number, but only for last digit. Therefore it is invalid.
If you put there a correct grep expression, like I posted, it will work as expected. The grep is there explicitly for capturing the error code in case of 1 to 5 failures.

> I want to change the test grep logic allowing 1-5 failure,
> to comment out unstable unit test with 1-5 failure like f25, master(rawhide).

AFAIK I do not think it is possible (or practical) to disable the failing tests, as they fail randomly. You would have to disable a great number of them.

Comment 9 Pavel Valena 2016-08-16 19:41:55 UTC
Rebase to Rails 5.0.0.1 in rawhide and f25 is complete.

However I have left buildroot override still active[1], because as of now I cannot 'smoke-test' Rails functionality due to missing rubygem-puma in Fedora.

```
$ rails s
 . . .
Could not find gem 'puma (~> 3.0)'
```

[1] https://bodhi.fedoraproject.org/overrides/?user=pvalena&expired=0

Comment 10 Vít Ondruch 2016-08-17 07:51:59 UTC
(In reply to Jun Aruga from comment #4)
> Also sqlite3 is not installed for some reason.

This is the reason:

http://pkgs.fedoraproject.org/cgit/rpms/sqlite.git/commit/?h=f24&id=262f80098c106e3739588229694b25e81c1f6723

Comment 11 Vít Ondruch 2016-08-17 07:54:31 UTC
(In reply to Pavel Valena from comment #5)
> Yes, Jun, you are right. the sqlite3 BuildRequire is missing there[1].

Actually, for this cases, when some specific executable is required, I would suggest to use "BR: %{_bindir}/sqlite3". Then it doesn't matter in which package this executable is stored and splits or merges as the one above have zero impact (in ideal world ;) ).

Comment 12 Vít Ondruch 2016-08-17 08:05:04 UTC
(In reply to Pavel Valena from comment #9)
> However I have left buildroot override still active[1], because as of now I
> cannot 'smoke-test' Rails functionality due to missing rubygem-puma in
> Fedora.
> 
> ```
> $ rails s
>  . . .
> Could not find gem 'puma (~> 3.0)'
> ```


Just comment out puma. WebRick will be used instead, which is just fine for smoketesting.

Comment 13 Pavel Valena 2016-08-17 10:05:25 UTC
(In reply to Vít Ondruch from comment #11)
> (In reply to Pavel Valena from comment #5)
> > Yes, Jun, you are right. the sqlite3 BuildRequire is missing there[1].
> 
> Actually, for this cases, when some specific executable is required, I would
> suggest to use "BR: %{_bindir}/sqlite3". Then it doesn't matter in which
> package this executable is stored and splits or merges as the one above have
> zero impact (in ideal world ;) ).

Yes, that is what I meant. AFAIK there is no sqlite3 package.

> Just comment out puma. WebRick will be used instead, which is just fine for smoketesting.

Ok, will do that, thanks.

Comment 14 Fedora Update System 2016-08-17 14:39:22 UTC
rubygem-actioncable-5.0.0.1-1.fc25 rubygem-actionmailer-5.0.0.1-1.fc25 rubygem-actionpack-5.0.0.1-2.fc25 rubygem-actionview-5.0.0.1-2.fc25 rubygem-activejob-5.0.0.1-1.fc25 rubygem-activemodel-5.0.0.1-1.fc25 rubygem-activerecord-5.0.0.1-1.fc25 rubygem-activesupport-5.0.0.1-1.fc25 rubygem-rails-5.0.0.1-1.fc25 rubygem-railties-5.0.0.1-2.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2016-5760339e76

Comment 15 Jun Aruga 2016-08-17 18:20:25 UTC
Created attachment 1191714 [details]
f24 - activerecord - Fix for CVE-2016-6317

I fixed for CVE-2016-6317 f24, rubygem-activerecord.
Though Later I have to fix rubygem-actionpack too to add its unit test.

Comment 16 Jun Aruga 2016-08-17 18:28:33 UTC
Created attachment 1191715 [details]
f24 - activerecord - Fix for CVE-2016-6317 #2

Sorry updated the patch.

Comment 17 Fedora Update System 2016-08-17 19:53:15 UTC
rubygem-actioncable-5.0.0.1-1.fc25, rubygem-actionmailer-5.0.0.1-1.fc25, rubygem-actionpack-5.0.0.1-2.fc25, rubygem-actionview-5.0.0.1-2.fc25, rubygem-activejob-5.0.0.1-1.fc25, rubygem-activemodel-5.0.0.1-1.fc25, rubygem-activerecord-5.0.0.1-1.fc25, rubygem-activesupport-5.0.0.1-1.fc25, rubygem-rails-5.0.0.1-1.fc25, rubygem-railties-5.0.0.1-2.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-5760339e76

Comment 18 Jun Aruga 2016-08-18 10:52:29 UTC
Created attachment 1191851 [details]
f24 - actionpack - Fix for CVE-2016-6317

Hi,
I uploaded the patch for CVE-2016-6317 now.
This patch is to add a unit test for previous rubygem-activerecord patch.

Could you check both patches?
Thanks.

Comment 19 Pavel Valena 2016-08-18 17:30:28 UTC
Created attachment 1191950 [details]
f24 - Tests enhancement

Hi Jun,

I have attached a patch which enhances the separate tests execution you have implemented (please apply it on top of your patch). I have also added some more tests which were failing if not run separately. Please merge the changes into your build. 
Otherwise it is fine.

The actionpack patch is also ok.

Comment 20 Jun Aruga 2016-08-19 11:22:15 UTC
Created attachment 1192112 [details]
f24 - activerecord - Fix for CVE-2016-6317 #3

Pavel, thanks for your patch. Your way is better.
I merged your patch with squash.

I just modified a little bit more following ruby style used in Rubocop.

https://github.com/bbatsov/ruby-style-guide
- multi-line method chaining style.
- Limit lines to 80 characters

I uploaded a patch again.

Comment 21 Pavel Valena 2016-08-19 12:47:18 UTC
Jun,

sure, looks good.

I have just forgotten to mention a typo in %changelog:

'compativility'

LGTM :)

Comment 22 Jun Aruga 2016-08-19 13:34:56 UTC
Created attachment 1192143 [details]
f24 - activerecord - Fix for CVE-2016-6317 #4

Thanks, I fixed the typo.
I uploaded a patch again.

Comment 23 Jun Aruga 2016-08-19 13:38:46 UTC
Created attachment 1192144 [details]
f23 - activerecord - Fix for CVE-2016-6317

I updated a patch for f23 activerecord.
f23's ruby version is 2.2.5.
We do not need the Ruby 2.3 compatibility patch file for f23.

Comment 24 Jun Aruga 2016-08-19 14:11:11 UTC
Created attachment 1192151 [details]
f23 - actionpack - Fix for CVE-2016-6317

Hi, I uploaded a patch for f23 actionpack.
The content is almost same with f24 version.

Comment 25 Fedora Update System 2016-08-19 16:59:45 UTC
rubygem-activerecord-4.2.5.2-2.fc24 rubygem-actionpack-4.2.5.2-3.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-b4919ffe56

Comment 26 Fedora Update System 2016-08-19 16:59:56 UTC
rubygem-activerecord-4.2.3-3.fc23 rubygem-actionpack-4.2.3-6.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-f58d7ecc8a

Comment 27 Fedora Update System 2016-08-19 23:20:16 UTC
rubygem-actionpack-4.2.3-6.fc23, rubygem-activerecord-4.2.3-3.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-f58d7ecc8a

Comment 28 Fedora Update System 2016-08-19 23:21:10 UTC
rubygem-actionpack-4.2.5.2-3.fc24, rubygem-activerecord-4.2.5.2-2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-b4919ffe56

Comment 29 Fedora Update System 2016-08-27 10:25:19 UTC
rubygem-actioncable-5.0.0.1-1.fc25, rubygem-actionmailer-5.0.0.1-1.fc25, rubygem-actionpack-5.0.0.1-2.fc25, rubygem-actionview-5.0.0.1-2.fc25, rubygem-activejob-5.0.0.1-1.fc25, rubygem-activemodel-5.0.0.1-1.fc25, rubygem-activerecord-5.0.0.1-1.fc25, rubygem-activesupport-5.0.0.1-1.fc25, rubygem-rails-5.0.0.1-1.fc25, rubygem-railties-5.0.0.1-2.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 30 Fedora Update System 2016-08-29 18:53:47 UTC
rubygem-actionpack-4.2.5.2-3.fc24, rubygem-activerecord-4.2.5.2-2.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 31 Fedora Update System 2016-08-29 21:21:46 UTC
rubygem-actionpack-4.2.3-6.fc23, rubygem-activerecord-4.2.3-3.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.