Skip to content

fix(connectors): use json.Marshal in CreateTestResult to prevent injection and panics - #341

Closed
Harishrs2006 wants to merge 1 commit into
microcks:masterfrom
Harishrs2006:fix/json-injection-create-test-result
Closed

fix(connectors): use json.Marshal in CreateTestResult to prevent injection and panics#341
Harishrs2006 wants to merge 1 commit into
microcks:masterfrom
Harishrs2006:fix/json-injection-create-test-result

Conversation

@Harishrs2006

Copy link
Copy Markdown
Contributor

Replace hand-rolled string concatenation in CreateTestResult with a typed struct and json.Marshal — special characters in serviceID, testEndpoint, and secretName are now safely escaped

  1. Eliminates JSON field injection risk when values come from environment variables or external sources in CI/CD pipelines
  2. Replace three panic() calls with proper error returns
  3. Add safe checked type assertion for the response id field instead of bare .(string) that panics on unexpected server response

Related issues: Fixes #340

…ction and panics

Replace hand-rolled string concatenation in CreateTestResult with a typed
struct and json.Marshal. The old approach embedded serviceID, testEndpoint,
and secretName directly into a JSON string without escaping, allowing:
- Malformed JSON when values contain quotes or backslashes
- JSON field injection when values contain control characters

Also replace three panic() calls with proper error returns, and add a safe
checked type assertion for the response 'id' field.

Fixes microcks#338

Signed-off-by: Harish R S <harishrs21082006@gmail.com>
@Caesarsage

Copy link
Copy Markdown
Contributor

Thanks for this! The typed-struct + json.Marshal approach (including validation of filteredOperations/headers/oauth sub-fields) landed on master, so this PR is superseded. The injection analysis in the description was on point.

I suggest closing this

@Harsh4902

Copy link
Copy Markdown
Member

Thanks @Caesarsage, I'm clossing this PR as it's already tackled.

@Harsh4902 Harsh4902 closed this Aug 19, 2026
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.

fix(connectors): CreateTestResult builds JSON via string concat — field injection and panic risks

3 participants