Skip to content

Fix registry security review findings (infrastructure#68) on gbif-common-ws 2.1.4 - #876

Merged
fmendezh merged 31 commits into
devfrom
security/registry-review-fixes
Nov 17, 2026
Merged

fmendezh merged 31 commits into
devfrom
security/registry-review-fixes

Conversation

@fmendezh

@fmendezh fmendezh commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes from the registry security review (gbif/infrastructure#68), on top of the gbif-common-ws security fixes in gbif/gbif-common-ws#33 (2.1.4-PR-33-SNAPSHOT). One commit per finding; most have tests.

Depends on gbif/gbif-common-ws#33: switch to the released 2.1.4 before merging.

Also upgrades gbif-api to 2.4.30-SNAPSHOT and download-query-tools to 2.0.13-SNAPSHOT (last commit): checklistKey of the GrSciColl search requests is now a UUID; download-query-tools 2.0.12 cannot build the human readable query with this gbif-api. Switch both to releases before merging.

Changes needed by gbif-common-ws 2.1.4

Change Why
URL level anyRequest().permitAll() Requests without credentials are no longer authenticated (gbif/informatics#53), so .authenticated() rejected every anonymous request, including public GETs. Endpoints stay secured by method security.
WebApplicationExceptionFilter after IdentityFilter IdentityFilter no longer catches exceptions from later filters (gbif/informatics#62); the registry filters throw WebApplicationException to reject requests.
DebugFilter removed Content-MD5 is now checked against the buffered body; DebugFilter read the parameters first, which emptied the body. Form parameters are read from the buffered body and multipart bodies are not buffered by gbif-common-ws (gbif/gbif-common-ws#33), so form Content-MD5 is verified; multipart Content-MD5 is not, as before 2.1.4.
/user endpoints check the user before the scheme The Authentication argument is now null without credentials; the scheme check answered 403 instead of 401.
IT fixture signs with the new scheme x-gbif-date, canonical URL with query, content type as sent, MD5 of the exact body.

Findings fixed

# Change
1, 2 DELETE/POST/PUT /doi require REGISTRY_ADMIN or APP (callers: occurrence-ws/event-ws with app keys, downloads with an admin user). Metadata is validated before it is saved.
3 Authorization filters match the path Spring MVC routes (decoded, no path parameters, no trailing slash); GrSciColl patterns accept uppercase UUIDs. Legacy IPT write endpoints require IPT_ROLE.
4 Legacy auth no longer logs or returns credentials; failures all answer 401 "Invalid credentials"; constant-time comparison; tokens generated with SecureRandom.
5 ?op=password response no longer contains the contact e-mail; JSONP callback must be a function name.
8 Confirming or revoking an endorsement needs rights on the endorsing node, also for ?checkPermissionsOnly=true.
9 (part) != on UUIDs in IPT dataset updates.
10 Invalid JWT answers 401 and stops instead of continuing as anonymous.
12 (part) Exact, constant-time password hash comparison; deleted users ignored by confirmations and password/e-mail changes.
13 (part) Batches and result files only for the creator and admins; suggestion upload extensions limited to .csv, .tsv, .txt.
15 Formula cells and headers in CSV/TSV exports neutralised when written (plain numbers and phone numbers of digits and spaces kept); Content-Disposition built with ContentDisposition.
16 (part) Stored metadata documents served with Content-Security-Policy: default-src 'none'; sandbox.
17 Endorsement eligibility check only for admins or the user themselves; 503s return a generic message.
19 (part) CLI configurations mask passwords and secrets in toString().
20 (part) avro 1.11.5, parquet 1.17.0.

Please review

  • Behaviour changes: plain users can no longer register/update DOIs; organisation-only editors can no longer endorse; an invalid/expired JWT gets 401 also on public endpoints; anonymous requests to secured endpoints get 403.
  • Deployment: gbif-common-ws 2.1.4 also needs appkeys.adminImpersonation configured (Review comments in the registry #55, warnings only by default) and every GBIF request signer updated to the new signature scheme.
  • Not addressed, need a decision: 6 (actuator exposure), 7 (GrSciColl import/convert/reinterpret scope), 9 (IPT re-homing: the update carries only the new organisation key), 11 (current password on change, app keys minting tokens), 12 (challenge code expiry, bcrypt), 13 (anonymous suggestions, size, e-mails), 14 (Freemarker escaping, ~100 templates to check), 18 (rate limiting), 19 (IT JWT key, example confs, hbase-site.xml), 20 (woodstox, zookeeper, hadoop), 21 (CORS, ShedLock, OAI transformer; page and facet sizes are already capped).

Testing

mvn verify with -Dappkeys.testfile pointing at a keys file containing gbif.app.it2 (the repo's appkeys-test.properties lacks it, so ~230 client-mode ITs fail without it, on dev too): unit tests all pass; integration tests 908 run, 0 failures, 34 skipped. 3 registry-cli ITs could not run locally for lack of the registry-cli-it.* settings properties.

Finding 1 and 2 of gbif/infrastructure#68.

- DELETE /doi/{prefix}/{suffix} had no authorization: any caller, including
  anonymous ones, could request the deletion of any DOI.
- POST/PUT /doi let any logged-in user register or rewrite the metadata of
  any DOI.

The only callers are occurrence-ws/event-ws (app keys) and the download
workflow (admin user), so all three now require REGISTRY_ADMIN or APP.
Metadata is also validated before it is saved, so invalid metadata is no
longer persisted.
Finding 3 of gbif/infrastructure#68.

The editor, GrSciColl editor, legacy, pre-check and not-found filters matched
anchored regexes against the raw request URI and let the request through when
nothing matched. Spring MVC decodes the URI, drops path parameters and ignores
a trailing slash, so e.g. PUT /dataset/{key}/, an encoded dash or ;a=b reached
the handler without the per-entity check. GrSciColl patterns also rejected
uppercase UUIDs, which UUID.fromString accepts.

The filters now use RequestPathUtils.normalizedPath: the path within the
application, decoded, without path parameters, repeated or trailing slashes.
GrSciColl and not-found patterns accept uppercase hex.
Finding 4 of gbif/infrastructure#68.

- The Authorization header and decoded user:password were logged, and
  returned in the 401 body when the user was not a UUID (any normal user
  hitting a legacy endpoint). Neither is logged or returned now.
- Invalid Base64 or organisationKey gave 500, now 400.
- Unknown key, wrong organization password and wrong installation password
  gave different messages, revealing which keys exist. All are now
  401 "Invalid credentials".
- Passwords are compared in constant time.
- Organization shared tokens are generated with SecureRandom instead of
  java.util.Random.

Tokens are still stored in plain text: the ?op=password reminder e-mails
them, so hashing them needs that feature retired first.
- Requests without credentials are no longer authenticated
  (gbif/informatics#53), so anyRequest().authenticated() rejected every
  anonymous request, including public GETs. The URL level now uses
  permitAll(); endpoints were and stay secured by method security, which
  now rejects anonymous callers for real.
- IdentityFilter no longer catches exceptions thrown further down the chain
  (gbif/informatics#62). The registry filters throw WebApplicationException
  to reject requests, so a new WebApplicationExceptionFilter right after
  IdentityFilter answers them with their status and message.
Finding 10 of gbif/infrastructure#68.

JwtRequestFilter set 401 on an invalid or expired JWT but continued the
chain, so the request ran as anonymous and endpoints without @secured still
did their work. It now answers 401 and stops.

Token revocation, an absolute lifetime and invalidation on password change
are not part of this change.
…cks callback

Finding 5 of gbif/infrastructure#68.

- GET /registry/organisation/{key}?op=password needs no authentication and
  returned the primary contact's e-mail address. The reminder is still sent,
  but the response no longer contains the address.
- The JSONP callback is written as JavaScript in the response; anything but
  a plain function name is now rejected with 400.
Finding 17 of gbif/infrastructure#68.

- GET /organization/{key}/endorsement/user/{user} told anyone whether any
  user could endorse for a node. Non-admins can now only ask about
  themselves (registry-console asks for the logged-in user).
- Async requests failing with 503 returned the internal exception message;
  it is logged and a generic message is returned. 400 messages are kept,
  they describe the invalid parameter.
Finding 15 of gbif/infrastructure#68.

- Exported cells starting with = + - @ were run as formulas by spreadsheet
  applications (dataset search, GrSciColl and download exports). They are
  now prefixed with a quote, except numbers and phone numbers.
- The descriptor suggestion download built Content-Disposition by
  concatenating the user supplied title, which could break out of the
  quotes. It is now built with ContentDisposition.

Contact details in public GrSciColl exports are unchanged.
Part of finding 13 of gbif/infrastructure#68.

- GET /grscicoll/{collection|institution}/batch/{key} and its resultFile
  were open to anyone, with sequential keys, and the result file contains
  contacts. Only the user who created the batch and admins can read them.
- The extension of an uploaded descriptor suggestion file was taken from
  the client file name, which could contain path separators or e.g. .html.
  Only .csv, .tsv and .txt are kept; anything else is stored as .csv.

Anonymous suggestions, their upload size and the e-mails they trigger are
unchanged.
Part of finding 16 of gbif/infrastructure#68.

GET /dataset/{key}/document and /dataset/metadata/{key}/document return the
XML uploaded by publishers as application/xml. A browser opening one could
run an XHTML script in it on the API origin. These responses now carry
Content-Security-Policy: default-src 'none'; sandbox (nosniff was already
sent). They still display in browsers.

The XXE posture of the external metadata and phylogeny parsers is not
checked here.
Since gbif-common-ws 2.1.4 the Authentication argument of a request without
credentials is null instead of an anonymous token. The scheme checks treat
null as 403, so /user/login without credentials answered 403. The user is now
checked first, which answers 401 as before.
The test fixture built GBIF signatures by hand with the old scheme. It now
sends and signs x-gbif-date, the canonical URL with its query string, the
content type as sent and the Content-MD5 of the exact body (it used to hash
the JSON body serialized a second time).
Part of findings 3 and 9 of gbif/infrastructure#68.

The legacy register/update/delete endpoints had no method security: only
LegacyAuthorizationFilter, which recognises them by path, authenticated the
IPT. A path it did not recognise, e.g. DELETE /registry/service/, reached
the handler without credentials (deleteAllDatasetEndpoints). They now
require IPT_ROLE, which the legacy authentication carries.
Finding 8 of gbif/infrastructure#68.

PUT/DELETE /organization/{key}/endorsement were checked by the editor filter
against rights on the organization or its node, so an editor of the
organization itself could endorse it. Endorsement is a node decision: like
userAllowedToEndorseOrganization, non-admins now need rights on the
endorsing node.
Part of finding 19 of gbif/infrastructure#68.

DbConfiguration, DataCiteConfiguration and DirectoryConfiguration printed
the database password, DataCite password and app secret in toString(), which
the CLI services log at startup (e.g. VocabularySynchronizerService). They
are masked now.
…users

Part of finding 12 of gbif/infrastructure#68.

- Password hashes were compared with equalsIgnoreCase, although their
  alphabet is case sensitive (Drupal itself compares them exactly). They
  are now compared exactly and in constant time.
- Key based confirmations, password reset/change and e-mail change looked
  the user up with getByKey, which returns deleted users. They now ignore
  deleted users.

Challenge codes still do not expire and the hashing is still Drupal 7
SHA-512.
…n-ws 2.1.4

gbif-common-ws 2.1.4 checks the Content-MD5 of GBIF signed requests against
the buffered body. Signed uploads (dataset documents, descriptor suggestions)
were rejected with 401:

- DebugFilter, first in the chain, called getParameterMap() only to log a
  debug line. For multipart and form bodies that makes the container parse
  and consume the body before HttpServletRequestWrapperFilter buffers it, so
  the buffered body was empty. It is removed.
- Without it the body is buffered, but then the container finds no multipart
  parts or form parameters in the consumed input stream. The new
  FormBodyRequestWrapperFilter wraps multipart and form requests without
  buffering, which HttpServletRequestWrapperFilter leaves as they are; their
  Content-MD5 is not verified, as before 2.1.4.

This is better handled in gbif-common-ws itself (do not buffer these
content types in GbifHttpServletRequestWrapper).
Part of finding 20 of gbif/infrastructure#68: avro 1.11.3 (CVE-2024-47561)
and parquet-avro 1.12.3 (CVE-2025-30065). parquet 1.17.0 is built with avro
1.11.5. woodstox-core-asl, zookeeper and hadoop are unchanged.
Part of finding 9 of gbif/infrastructure#68. The UUIDs were compared with
!=, so the change of installation was logged for every update; the log also
had the old and new keys swapped.
…NAPSHOT

gbif-api 2.4.30 changed the checklistKey of the GrSciColl search requests
from String to UUID:

- the services convert it to String for the mapper params, falling back to
  defaultChecklistKey as before;
- the checklistKey query parameter is parsed as a UUID, an invalid value is
  an IllegalArgumentException;
- tests use UUIDs, random ones where the key only had to match nothing.

download-query-tools 2.0.13-SNAPSHOT is needed with this gbif-api: 2.0.12
fails to build the human readable query and falls back to the predicate as
JSON in download DOI descriptions (DownloadConverterTest).
@fmendezh
fmendezh requested a balanced review from Copilot November 17, 2026 09:17
@fmendezh
fmendezh force-pushed the security/registry-review-fixes branch from 2b6893e to 7807b7b Compare November 17, 2026 09:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Signed form bodies can bypass integrity verification, and CSV/TSV exports remain vulnerable to formula injection; anonymous authentication and permission prechecks also have unresolved errors.

6 open issues
What changed in this PR

Addresses registry security-review findings and adapts the registry to the authentication and request-signing changes in gbif-common-ws 2.1.4.

Changes:

  • Tightens authorization for DOI writes, legacy IPT operations, endorsements, and batch access.
  • Hardens credential handling, user-account updates, exports, metadata responses, and error messages.
  • Updates dependencies, adopts UUID checklist keys, and adds regression tests and revised signing fixtures.

The snapshot dependencies still need released versions before merging, as noted in the PR description.

File Description
registry-ws/​src/​test/​java/​org/​gbif/​registry/​ws/​export/​CsvWriterTest.java Tests formula neutralization and preserved values.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​resources/​UserResource.java Reorders authentication and scheme checks.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​resources/​OrganizationResource.java Secures password generation and endorsement checks.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​resources/​legacy/​LegacyOrganizationResource.java Validates callbacks and hides reminder email addresses.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​resources/​legacy/​LegacyEndpointResource.java Requires the IPT role for writes.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​resources/​legacy/​LegacyDatasetResource.java Adds role checks to legacy dataset writes.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​resources/​legacy/​IptResource.java Adds role checks and corrects UUID comparison.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​resources/​DoiInteractionResource.java Restricts writes and validates metadata before persistence.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​resources/​collections/​CollectionResource.java Safely constructs download disposition headers.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​resources/​collections/​BaseCollectionEntityResource.java Restricts batch and result-file access.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​provider/​CollectionDescriptorsSearchRequestHandlerMethodArgumentResolver.java Parses checklist keys as UUIDs.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​export/​CsvWriter.java Adds spreadsheet-formula neutralization.
registry-ws/​src/​main/​java/​org/​gbif/​registry/​ws/​exception/​AsyncExceptionHandler.java Logs internal errors and returns generic messages.
registry-service/​src/​main/​java/​org/​gbif/​registry/​service/​collections/​descriptors/​DescriptorChangeSuggestionServiceImpl.java Limits generated filenames to allowed extensions.
registry-service/​src/​main/​java/​org/​gbif/​registry/​service/​collections/​descriptors/​DefaultDescriptorService.java Adapts descriptor queries to UUID checklist keys.
registry-service/​src/​main/​java/​org/​gbif/​registry/​service/​collections/​CollectionsSearchService.java Adapts collection queries to UUID checklist keys.
registry-security/​src/​test/​java/​org/​gbif/​registry/​security/​util/​RequestPathUtilsTest.java Tests request-path normalization.
registry-security/​src/​test/​java/​org/​gbif/​registry/​security/​LegacyAuthorizationServiceImplTest.java Tests legacy authentication and sanitized failures.
registry-security/​src/​test/​java/​org/​gbif/​registry/​security/​grscicoll/​GrSciCollEditorAuthorizationFilterTest.java Tests uppercase and trailing-slash authorization paths.
registry-security/​src/​test/​java/​org/​gbif/​registry/​security/​EditorAuthorizationFilterTest.java Tests encoded and parameterized authorization paths.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​WebApplicationExceptionFilter.java Converts filter exceptions into HTTP responses.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​util/​RequestPathUtils.java Centralizes authorization-path normalization.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​ResourceNotFoundRequestFilter.java Uses normalized paths and uppercase UUID matching.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​precheck/​AuthPreCheckCreationRequestFilter.java Normalizes permission-precheck paths.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​LegacyAuthorizationServiceImpl.java Sanitizes failures and compares credentials securely.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​LegacyAuthorizationFilter.java Uses normalized paths for legacy authorization.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​jwt/​JwtRequestFilter.java Stops requests with invalid JWTs.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​grscicoll/​GrSciCollEditorAuthorizationFilter.java Normalizes paths and accepts uppercase UUIDs.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​FormBodyRequestWrapperFilter.java Preserves servlet form and multipart parsing.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​EditorAuthorizationFilter.java Applies authorization to normalized paths.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​DebugFilter.java Removes eager form-parameter parsing.
registry-security/​src/​main/​java/​org/​gbif/​registry/​security/​config/​WebSecurityConfigurer.java Updates filter ordering, anonymous routing, and metadata headers.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​UserManagementIT.java Tests deleted-user mutation restrictions.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​security/​jwt/​JwtIT.java Expects unauthorized responses for invalid tokens.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​OrganizationCreationIT.java Tests endorsement rights and eligibility-query restrictions.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​legacy/​LegacyOrganizationResourceIT.java Tests reminder privacy and callback rejection.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​legacy/​LegacyEndpointResourceIT.java Tests rejection of anonymous endpoint deletion.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​fixtures/​RequestTestFixture.java Implements the revised request-signing scheme.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​DoiRegistrationIT.java Tests DOI write authorization.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​DatasetIT.java Tests metadata-document content security headers.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​collections/​service/​descriptors/​DescriptorsServiceIT.java Updates descriptor tests for UUID checklist keys.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​collections/​service/​CollectionsSearchIT.java Updates collection-search tests for UUID checklist keys.
registry-integration-tests/​src/​test/​java/​org/​gbif/​registry/​ws/​it/​collections/​resource/​BaseCollectionEntityResourceIT.java Tests protected batch and result-file reads.
registry-identity/​src/​test/​java/​org/​gbif/​registry/​identity/​util/​RegistryPasswordEncoderTest.java Tests exact password-hash matching.
registry-identity/​src/​main/​java/​org/​gbif/​registry/​identity/​util/​RegistryPasswordEncoder.java Uses null-safe, constant-time hash comparison.
registry-identity/​src/​main/​java/​org/​gbif/​registry/​identity/​service/​IdentityServiceImpl.java Excludes deleted users from account changes.
registry-cli/​src/​main/​java/​org/​gbif/​registry/​cli/​common/​DirectoryConfiguration.java Masks application secrets in string output.
registry-cli/​src/​main/​java/​org/​gbif/​registry/​cli/​common/​DbConfiguration.java Masks database passwords in string output.
registry-cli/​src/​main/​java/​org/​gbif/​registry/​cli/​common/​DataCiteConfiguration.java Masks DataCite passwords in string output.
pom.xml Updates dependencies and adds snapshot repository access.

Review effort: Balanced

Comment on lines +44 to +45
if (isFormBody(request) && !(request instanceof GbifHttpServletRequestWrapper)) {
filterChain.doFilter(new GbifHttpServletRequestWrapper(request, false), response);

@fmendezh fmendezh Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in gbif-common-ws (gbif/gbif-common-ws#33, c15712c12): the wrapper now buffers application/x-www-form-urlencoded bodies and serves their parameters from the buffer, so their Content-MD5 is verified. FormBodyRequestWrapperFilter is removed here (d0ff1d4). Multipart bodies are still not buffered, so the container can parse their parts; their Content-MD5 is not verified, as before 2.1.4. That is documented in the gbif-common-ws changelog.

Comment on lines +716 to +718
String cleaned = DELIMETERS_MATCH_PATTERN.matcher(value).replaceAll(" ");
if (FORMULA_START_PATTERN.matcher(cleaned).find()
&& !NUMBER_LIKE_PATTERN.matcher(cleaned).matches()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7e742de: formulas are now neutralised by the CSV encoder (FormulaNeutralisingEncoder), so every cell is covered, including headers and columns without a processor (codes, identifiers, alternative codes, descriptor verbatim headers). Map keys are unchanged.

// anonymous since gbif-common-ws 2.1.4, .authenticated() would reject them on public endpoints
.authorizeHttpRequests(auth -> auth
.anyRequest().authenticated()
.anyRequest().permitAll()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d773e9c: without a user the precheck filter leaves the body unchanged, so the next filters reject the request. AuthPreCheckInterceptor answers 403 for a null authentication instead of throwing a NullPointerException.

Comment on lines +712 to +713
// numbers and phone numbers, e.g. -12.5 or +45 35 32 14 70, cannot be harmful formulas
private static final Pattern NUMBER_LIKE_PATTERN = Pattern.compile("^[+-]?[0-9 ().-]+$");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7e742de: only plain numbers (-12.5) and phone numbers made of digits and spaces (+45 35 32 14 70) are kept. -(1), -12-5 and +1-202-555-0144 are written as text.

Comment on lines +708 to +710
if (!canEndorse(organizationKey)) {
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a0021fa: EditorAuthorizationFilter checks rights on the endorsing node for PUT/DELETE /organization/{key}/endorsement (allowedToEndorseOrganization), so the precheck gives the same answer as the request itself.

// the user shall be authenticated using basic auth. scheme only.
ensureNotGbifScheme(authentication);
ensureUserSetInSecurityContext(authentication);
ensureNotGbifScheme(authentication);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4f51ed9: the user check now runs before the logging. Covered by UserIT.testBasicAuthNoCredentials.

?checkPermissionsOnly=true stops before the controller, so the node check of
PUT/DELETE /organization/{key}/endorsement in OrganizationResource did not
run and the editor filter accepted rights on the organization itself. The
filter now checks rights on the endorsing node for these paths.
…Exception

Requests without credentials reach the precheck filter and interceptor since
the security chain permits them. The filter no longer builds a body without a
user, leaving the request to the next filters, and the interceptor answers 403.
The debug logging dereferenced the missing authentication before the user check.
Code, identifier and alternative code columns and descriptor verbatim headers
skipped CleanStringProcessor. Formulas are now neutralised by the CSV encoder,
so every cell and header is covered. Only plain numbers and phone numbers of
digits and spaces are kept: -(1), -12-5 or +1-202-555-0144 would be calculated.
… bodies

gbif-common-ws (gbif/gbif-common-ws#33) now reads the parameters of buffered
form bodies from the buffer, so their Content-MD5 is verified, and does not
buffer multipart bodies.
@fmendezh
fmendezh force-pushed the security/registry-review-fixes branch from bbd836f to d0ff1d4 Compare November 17, 2026 10:28
@fmendezh
fmendezh requested a review from marcos-lg November 17, 2026 12:25
…line feeds

- reject anonymous tokens in ensureUserSetInSecurityContext and DOI generation
- an invalid Base64 Basic header is not an IPT validation request
- IdentityServiceImpl.update ignores deleted users
- neutralise cells starting with a line feed
- unit tests for WebApplicationExceptionFilter
@fmendezh

Copy link
Copy Markdown
Contributor Author

Follow-up to an external review of this PR. Each finding was checked against the code; fixes are in db878de.

Fixed

  • Anonymous access to POST /doi/gen/{type}: the gbif-common-ws anonymous token has a null name, so checkIsUserAuthenticated() already rejected it. Spring's own AnonymousAuthenticationToken ("anonymousUser") would pass, so it is now rejected there and in SecurityContextCheck.ensureUserSetInSecurityContext, with a test.
  • Invalid Base64 Basic header on /validation: the gbif-common-ws identity filter runs first and already answers 400. isValidationRequest now also returns false instead of throwing.
  • WebApplicationExceptionFilter had no tests: added WebApplicationExceptionFilterTest (status and body, committed response, buffer reset, other exceptions propagate).
  • Deleted users in IdentityServiceImpl.update: not reachable through the API (identityService.get skips deleted users), but update now uses getActiveUserByKey like the other methods.
  • CSV cells starting with a line feed are now neutralised, with tests for LF and CR.

Not changed

  • Invalid checklistKey → 500: it is a 400. gbif-common-ws' IllegalArgumentExceptionMapper is component-scanned by the registry app.
  • Snapshot dependencies (gbif-common-ws, gbif-api, gbif-directory, download-query-tools): released versions are needed before merging. gbif-directory 3.9-SNAPSHOT comes from ae382f3 (IT against directory).
  • Suggestion file download without authorization: suggestion details are public as well; this belongs with the decision on finding 13 (anonymous suggestions).
  • password = true on the JCommander @Parameters: JCommander would prompt for the password on the console. toString() already masks them.
  • Async 400 messages: same behaviour as the global IllegalArgumentExceptionMapper. The legacy-auth messages revealing key existence only go to the debug log, not to responses.
  • Test guarding unannotated write endpoints: some are open on purpose (login, whoami, anonymous suggestions, DOI generate), so it needs an allow-list. Better as a separate change.
  • More IT coverage (ADMIN/APP and IPT positive cases, batch creator/non-creator, upload extension rejection): not added in this round.

@fmendezh
fmendezh merged commit 2bf3793 into dev Nov 17, 2026
3 checks passed
@fmendezh
fmendezh deleted the security/registry-review-fixes branch November 17, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants