Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with downloading report #1827

Merged
merged 1 commit into from
Aug 4, 2017

Conversation

yrudman
Copy link
Contributor

@yrudman yrudman commented Aug 3, 2017

Issue: Connecting as admin user and executing download will set userid column in miq_report_result table to 'admin|2d7db0c5addb0eb91de3541c811ea02e|download'. As result record is not found for current_user.

https://bugzilla.redhat.com/show_bug.cgi?id=1471014

Solution: Do not check if curent_user can access data for downloading. We can remove this check since download button available only when specific report selected and visibility restriction was already applied to list of reports.

BEFORE:
before

AFTER:
after

@miq-bot add-label bug, fine/yes, euwe/yes

\cc @gtanzillo

…d column in miq_report_result table to 'admin|2d7db0c5addb0eb91de3541c811ea02e|download' and this user does not belong to any group. Solution: Reverting back to previous logic.

https://bugzilla.redhat.com/show_bug.cgi?id=1471014
@miq-bot
Copy link
Member

miq-bot commented Aug 3, 2017

Checked commit yrudman@9e3e8bc with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks fine. 🏆

@yrudman
Copy link
Contributor Author

yrudman commented Aug 4, 2017

\cc @h-kataria @dclarizio

@h-kataria
Copy link
Contributor

looks good.

@h-kataria h-kataria self-assigned this Aug 4, 2017
@h-kataria h-kataria added this to the Sprint 66 Ending Aug 7, 2017 milestone Aug 4, 2017
@h-kataria h-kataria merged commit 282755e into ManageIQ:master Aug 4, 2017
@yrudman yrudman deleted the fix-downloading-reports branch August 8, 2017 12:52
simaishi pushed a commit that referenced this pull request Aug 9, 2017
@simaishi
Copy link
Contributor

simaishi commented Aug 9, 2017

Fine backport details:

$ git log -1
commit cd6dce3934f327a305f8313280f1e6ff9c3e7afe
Author: Harpreet Kataria <hkataria@redhat.com>
Date:   Fri Aug 4 09:51:45 2017 -0400

    Merge pull request #1827 from yrudman/fix-downloading-reports
    
    Fixed issue with downloading report
    (cherry picked from commit 282755ef8662022271b5ca55446a81ca4220a4d5)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1479994

@simaishi
Copy link
Contributor

Euwe backport (to manageiq repo) details:

$ git log -1
commit 024c1b49e851ac947cc1bf6c864a952c74504d6c
Author: Harpreet Kataria <hkataria@redhat.com>
Date:   Fri Aug 4 09:51:45 2017 -0400

    Merge pull request #1827 from yrudman/fix-downloading-reports
    
    Fixed issue with downloading report
    (cherry picked from commit 282755ef8662022271b5ca55446a81ca4220a4d5)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1481743

@ZitaNemeckova
Copy link
Contributor

ZitaNemeckova commented Aug 29, 2017

@yrudman @h-kataria Same problem in Cloud Intel -> Dashboard -> FullScreen/Download PDF.

On lines https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/application_controller.rb#L574 and https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/application_controller/report_downloads.rb#L54 .

Not sure if it should be solved in the same way... because it was introduced by #1627 .

@martinpovolny
Copy link
Member

martinpovolny commented Aug 30, 2017

Solution: Do not check if curent_user can access data for downloading. We can remove this check since download button available only when specific report selected and visibility restriction was already applied to list of reports.

Sorry, but this is wrong. It's very easy to get around such check. You cannot trust the browser/user/the Internet that an action will not be executed because the button is not there. This creates a security issue.

This issue needs to be fixed differently.

@martinpovolny
Copy link
Member

@simaishi : this should not get released

@himdel
Copy link
Contributor

himdel commented Aug 30, 2017

See discussion from #1627 (comment) on.

TLDR: we can probably find all the places which don't set miq_group_id, but I have no idea what value of miq_group_id would actually make any sense.

@yrudman
Copy link
Contributor Author

yrudman commented Aug 30, 2017

@simaishi
Downloading report done in 3 phases:

  1. Request for download - it could be initiated ONLY by user who is in compliance with CVE-2016-7047 patch here:
    rr = MiqReportResult.for_user(current_user).find(session[:report_result_id]) # Get report task id from the session
    . Result of request for download is temporary record in MiqReportTabe
  2. Download actual report
  3. Delete temporary record

Security check removed from temporary record.

I agree, solution is not perfect (since something could go wrong in step 2 and temp record could become permanent) but not as bad as looks like, or I am missing something ?

@martinpovolny
Copy link
Member

Ok, cool @yrudman. I have read the explanation in the PR description and that sounded much worse than it probably is.

I'll leave this to you guys @yrudman @himdel @isimluk

@himdel
Copy link
Contributor

himdel commented Aug 30, 2017

I think this particular fix is really not a security regression per se.

The only problem with this fix is that it doesn't fix all the places, and fixing them the same way would be a security regression. So.. this is OK, but dangerous if anybody copies it.

So... maybe let's focus on fixing it properly instead, so we can keep all the fixes the same?

@yrudman What do you know about what report results should be actually visible to which user?

Do you have any answer to my question here? - Should the report results really be visible to any member of the current group of the user who generated it?

@yrudman
Copy link
Contributor Author

yrudman commented Aug 30, 2017

right, this fix can not be blindly copied.
Common stuf, i think, we can remove security check where report id taken from session.

It looks like that different workflows related to reports should be treated differently.
For example issue with widgets: Widgets can be available by role and group, MiqReportResult.userid will have pipe separated list of groups which have access to this record and having single MiqReportResult.miq_group_id will not work;

screen shot 2017-08-30 at 9 32 07 am

EDIT: it looks like different record created for different group, look at record starting with widget_id_6

@himdel
Copy link
Contributor

himdel commented Aug 30, 2017

Ah, there can be multiple groups in there? Any idea where that would come from?

All I can see is that userid = "#{options[:userid]}|#{options[:session_id]}|#{options[:mode]}" which ...would fit the format, but not sure if this always comes from there, especially since those groups in the middle don't look like session_id to me :).

But .. in the screenshot, only the middle field is a group, so so far I'm not seeing any evidence of multiple groups being supported.

@himdel
Copy link
Contributor

himdel commented Aug 30, 2017

Widgets can be available by role and group

Ah, so this mechanism is definitely insuficcient and will need at least a role support added, good to know :).

I wonder if it makes more sense to fix that for_user scope to check for these (but have to parse strings) or to add new db fields, WDYT?

EDIT: actually, silly question, definitely need to add role id field if that is something we need to support.

@yrudman
Copy link
Contributor Author

yrudman commented Aug 30, 2017

Any idea where that would come from?

screen shot 2017-08-30 at 9 57 04 am

@himdel
Copy link
Contributor

himdel commented Aug 30, 2017

Yet I can see only one of those groups in that field..

So we're probably losing that data right now, right? (Or, keeping it in widget, but not in the report result.)

@yrudman
Copy link
Contributor Author

yrudman commented Aug 30, 2017

we are not loosing it,
there is one record per group in miq_report_results: (I was wrong assuming multiple groups pipe separated), it used to create custom dashboards
screen shot 2017-08-30 at 10 08 52 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants