Remove pg_featureserv - #786
Open
oskarhurst wants to merge 1 commit into
Open
Conversation
The /features proxy exposed pg_featureserv unauthenticated: the route was registered on the root router rather than under the authenticated api group, so no JWT or key auth applied to it. No consumer was found. Searched cumulus-api, cumulus-ui and hec-rts: the UI gets spatial data from /watersheds and /user-regions, and the HEC-RTS CAVI importer uses /products, /watersheds and /downloads over the authenticated /api routes. Nothing referenced /features or the OGC collections endpoints. The image is prebuilt upstream (ghcr.io/cwbi-apps/pg_featureserv:1.3.1) with no apt step, so its CVEs cannot be fixed here and 1.3.1 is already the current upstream release. One finding, pgx/v4, has no fix on the v4 line at all. Removes the proxy route, its middleware, the config field, the image build context, the three build-push workflows and the compose service. Leaves sql/common/R__01_roles.sql untouched: cumulus_reader is part of the general permission model, not specific to this service.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes
pg_featureservand the/featuresproxy from this repo.Why
It was exposed without authentication. In
api/main.gothe route was registered on theroot router, not under the authenticated
apigroup:JWT and key auth are attached to
private := api.Group(""), so neither applied here. Everyrequest to
/features/*was proxied straight through to pg_featureserv.No consumer could be found. Searched three codebases:
cumulus-ui/features,featureserv,collectionsorogc. Requests are all built fromVITE_CUMULUS_API_URL(.../api), and/featuresis a sibling of/api, so the UI cannot reach it. Spatial data comes from/watershedsand/user-regions, rendered with Leaflet.hec-rtsusace/cavi/client/extract/cumulus) uses/products,/watershedsand/downloadsover the authenticated/apiroutes.cumulus-apiIts CVEs cannot be fixed here.
pg_featureserv/DockerfilewasFROM ghcr.io/cwbi-apps/pg_featureserv:1.3.1-amd64plus an entrypoint — a prebuilt binarywith no
aptstep, so neither a rebuild nor a dependency bump in this repo reaches it.1.3.1is the current upstream release from CrunchyData, so there is no newer version to move to, and
github.com/jackc/pgx/v4has no fix on the v4 line at all (EOL; fixed only in v5).Keeping it meant owning an unauthenticated, unpatchable service with no identified user.
Changes
api/main.go/featuresgroup and proxyapi/middleware/proxy-pgfeatureserv.goapi/config/config.goPgFeatureservUrl/PG_FEATURESERV_URLapi/middleware/gzip.go/featuresskip; keep the/cog/byte-range skippg_featureserv/.github/workflows/cwbi-{dev,test,prod}-build-push-pg_featureserv.ymldocker-compose.ymlfeatureservservice andPG_FEATURESERV_URLdocker-compose.tests.ymlPG_FEATURESERV_URLDeliberately not changed
sql/common/R__01_roles.sql. It carries a comment saying theGRANT USAGE ON SCHEMA cumulus TO cumulus_readerwas added "to make pg_featureserv work", butcumulus_readerisnot specific to this service: it is granted to
cumulus_user(line 48) and used byR__03_views_watersheds.sqlandR__04_views_products.sql. Removing the grants would breakunrelated things.
The comment is now stale, but this is a Flyway repeatable migration — editing it changes
the checksum and re-runs it on the next deploy. Not worth triggering for a comment, so it is
left as-is. Happy to follow up separately if you would rather it be corrected.
Required follow-up outside this repo
Merging this stops the image being built. It does not stop the deployed service running,
so please treat these as part of the same change:
pg_featureservservice and remove the/featuresroute fromthe ALB / ingress. Until this happens the unauthenticated endpoint is still live.
cumulus-pg_featureservECR repository, or it will keep being scanned andkeep generating CVE issues for an image nobody builds.
Related issues
Deliberately
Refs, notCloses. The vulnerable service keeps running until step 1above is done, and auto-closing 22 security issues on merge would mark live vulnerabilities as
resolved. Please close them by hand once deprovisioning is confirmed.
Fully resolved once deprovisioned —
pg_featureservis the only module on these:Refs USACE/cumulus-issue-tracking#6, refs USACE/cumulus-issue-tracking#19, refs USACE/cumulus-issue-tracking#7, refs USACE/cumulus-issue-tracking#8, refs USACE/cumulus-issue-tracking#37, refs USACE/cumulus-issue-tracking#9, refs USACE/cumulus-issue-tracking#97
github.com/jackc/pgx/v4— no fix on v4 at allgithub.com/getkin/kin-openapi— auth bypassgithub.com/getkin/kin-openapigithub.com/jackc/pgproto3/v2libaclcoreutils-singlegithub.com/getkin/kin-openapiModule set shrinks only — these also affect other modules and stay open:
Refs USACE/cumulus-issue-tracking#10, refs USACE/cumulus-issue-tracking#11, refs USACE/cumulus-issue-tracking#2, refs USACE/cumulus-issue-tracking#24, refs USACE/cumulus-issue-tracking#30, refs USACE/cumulus-issue-tracking#36, refs USACE/cumulus-issue-tracking#39, refs USACE/cumulus-issue-tracking#40, refs USACE/cumulus-issue-tracking#41, refs USACE/cumulus-issue-tracking#42, refs USACE/cumulus-issue-tracking#43, refs USACE/cumulus-issue-tracking#4, refs USACE/cumulus-issue-tracking#82, refs USACE/cumulus-issue-tracking#83, refs USACE/cumulus-issue-tracking#91
The next scan sync will drop
pg_featureservfrom their module labels automatically.Testing
Not built, not run. Neither Go nor Docker is available on the machine this was prepared
on, so this is an inspection-only change. Gate on
cwbi-test-build-push-api.Checked by hand in place of a compiler:
middlewareis still used inmain.go(41 otherreferences),
stringsis still used ingzip.goby the/cog/skip, and no reference tofeatureservorPG_FEATURESERV_URLremains anywhere outside the SQL comment noted above.If this is wrong
If someone is using
/features— another CWBI app, a QGIS/ArcGIS layer pointed at the OGCendpoint, or the pg_featureserv browse UI — this PR breaks them, and the search above would
not have found it. The route and the
cumulus_readergrant were both added deliberately, soit is worth a quick check with whoever added them before merging. Access logs on
/featureswould settle it faster than any code search.