vulnerablecode icon indicating copy to clipboard operation
vulnerablecode copied to clipboard

Do not leak internal database ids in the API

Open pombredanne opened this issue 3 years ago • 9 comments

In this we have URLs such as

  • "url": "http://public.vulnerablecode.io/api/vulnerabilities/1265",
  • "url": "http://public.vulnerablecode.io/api/packages/168702", that leak internal record ids/primary keys. We should provide either a GUID or a natural key instead.
[
  {
    "url": "http://public.vulnerablecode.io/api/packages/168702",
    "purl": "pkg:maven/junit/[email protected]",
    "type": "maven",
    "namespace": "junit",
    "name": "junit",
    "version": "4.12",
    "qualifiers": {},
    "subpath": "",
    "affected_by_vulnerabilities": [
      {
        "url": "http://public.vulnerablecode.io/api/vulnerabilities/1265",
        "vulnerability_id": "VCID-e1bu-4uh4-aaac",
        "summary": "",
....

pombredanne avatar Nov 12 '22 11:11 pombredanne

Hey, I have a question. what's the expected result you wanna have? from what i've understood it's this

For example, instead of: "http://public.vulnerablecode.io/api/vulnerabilities/1265"

It could be: "http://public.vulnerablecode.io/api/vulnerabilities/abcdefg-1234-5678-90ab-cdefghijklmn"

Please correct me if i'm wrong

uzaxirr avatar Jan 21 '23 05:01 uzaxirr

@TG1999 @pombredanne ^^

uzaxirr avatar Jan 28 '23 04:01 uzaxirr

How about VCID and purl in public urls ? This would make the URLs independent of database deletion/re-creation, if it so happens. Also, multiple instances will be very explicit about which vulnerability/package they're pointing at by just looking at the url.

EDIT: Just realized VCID is based on UUID so this might not be as good.

Hritik14 avatar Jan 29 '23 18:01 Hritik14

IMHO we should use the natural keys of each model: vcid and purl

pombredanne avatar Feb 02 '23 21:02 pombredanne

As I can infer from the discussion, is it okay to reference the URLs via the natural key instead of UUID. This means that the natural key is a different entity other than the primary key right?

suraj-mandal avatar Mar 23 '23 20:03 suraj-mandal

I checked, and this problem still exists. If you are willing to work on a solution, I would like to take up the case.

Mohit-majumdar avatar Jan 19 '24 12:01 Mohit-majumdar

@Mohit-majumdar sure, feel free to work on this issue

TG1999 avatar Jan 19 '24 12:01 TG1999

I have discovered the true cause of this primary key, which is that the HyperlinkModel Serializer is being used. The question at hand is: will we use the VCID field or something else in place of the PK field? @TG1999 or @Hritik14 can someone please help me with this?

Mohit-majumdar avatar Jan 21 '24 17:01 Mohit-majumdar

@Mohit-majumdar we would want to use either a natural key (may be VCID or package_url) or a UUID

pombredanne avatar Jan 21 '24 23:01 pombredanne