Skip to content

Replace Vulnerabilities::Feedback.only_valid_feedback without joining ci

What does this MR do?

This method joins between ci_* and non ci_* tables and as such we need to replace this logic with something that does not do this join before we move ci_* tables to a different database.

This method Vulnerabilities::Feedback.only_valid_feedback was introduced originally in https://gitlab.com/gitlab-org/security/gitlab/-/merge_requests/117 to solve a security vulnerability #24932 (closed). The basic issue was that we had a controller that allowed you to create a Vulnerability::Feedback and set the pipeline_id of that. The problem is that for a window of time a user could have set the pipeline_id to be from a different project. We also had another controller that would present the path for a pipeline and as such you could learn the path of private projects by guessing the pipeline_id from other projects.

The original fix used a join ci_pipelines to filter out any Vulnerabilities::Feedback that happened to be associated to another project. We can't do this join anymore. It seemed simpler to change the security fix to focus on not rendering the pipeline if the project_id was belonging to a different project. So instead we just don't return pipeline if the project_id is not what it should be (ie. they hacked the pipeline_id to be a different project). This may present some issue in the frontend but this data should only appear if the user in the project deliberately created this hack data so we shouldn't be concerned about the UX impact here.

It's also possible this fix improves performance for this endpoint as it doesn't need to do a redundant join.

Since this fixes the problem in a slightly different way it also required us to change the test slightly to assert the pipeline is filtered out now rather than the whole Feedback object.

Screenshots or Screencasts (strongly suggested)

Response from #index controller
[
  {
    "id": 34,
    "created_at": "2020-09-15T04:35:44.702Z",
    "project_id": 6,
    "author": {
      "id": 2,
      "name": "Federico Marvin",
      "username": "rosette",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/cb1972bb588ceb2cc9bf3ec91def7288?s=80&d=identicon",
      "web_url": "http://127.0.0.1:3000/rosette",
      "show_status": false,
      "path": "/rosette"
    },
    "finding_uuid": "c8a7c79c-0999-552f-af13-ffb0e971f7a3",
    "pipeline": {
      "id": 30,
      "path": "/flightjs/flight/-/pipelines/30"
    },
    "issue_iid": 35,
    "issue_url": "http://127.0.0.1:3000/flightjs/flight/-/issues/35",
    "category": "sast",
    "feedback_type": "issue",
    "branch": "master",
    "project_fingerprint": "83d45a74582942a7e4b0931f299ddb7275457c41",
    "dismissal_reason": null
  },
  {
    "id": 35,
    "created_at": "2020-09-15T04:35:44.761Z",
    "project_id": 6,
    "author": {
      "id": 2,
      "name": "Federico Marvin",
      "username": "rosette",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/cb1972bb588ceb2cc9bf3ec91def7288?s=80&d=identicon",
      "web_url": "http://127.0.0.1:3000/rosette",
      "show_status": false,
      "path": "/rosette"
    },
    "finding_uuid": "c4113eb0-258a-54a0-b58c-b9bde0a59575",
    "destroy_vulnerability_feedback_dismissal_path": "/flightjs/flight/-/vulnerability_feedback/35",
    "category": "sast",
    "feedback_type": "dismissal",
    "branch": "master",
    "project_fingerprint": "b418f9445ed71d99c74b61b113557823f431b693",
    "dismissal_reason": null
  }
]

How to setup and validate locally (strongly suggested)

Conformity

Availability and Testing

-->

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #336763 (closed)

Edited by Dylan Griffith

Merge request reports