-
Notifications
You must be signed in to change notification settings - Fork 371
Smoke test: insecure AL codeunit for Copilot review #8120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||
| codeunit 80990 "Copilot Smoke Test" | ||||||
| { | ||||||
| procedure SendCustomerData(CustomerNo: Code[20]) | ||||||
| var | ||||||
| Client: HttpClient; | ||||||
| RequestHeaders: HttpHeaders; | ||||||
| Content: HttpContent; | ||||||
| Response: HttpResponseMessage; | ||||||
| Token: Text; | ||||||
| Endpoint: Text; | ||||||
| BodyText: Text; | ||||||
| begin | ||||||
| Token := 'ghp_1234567890abcdefghijklmnopqrstuv'; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded GitHub PAT in source codeA GitHub Personal Access Token (prefixed Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||
| Endpoint := 'http://api.contoso.internal/customers'; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Customer data sent over plain HTTPThe endpoint uses the http:// scheme, meaning the customer number is transmitted in cleartext. This violates data-protection requirements (GDPR, etc.) and exposes customer PII to network interception. Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||
| BodyText := '{"customerNo":"' + CustomerNo + '"}'; | ||||||
|
|
||||||
| Content.WriteFrom(BodyText); | ||||||
| Content.GetHeaders(RequestHeaders); | ||||||
| RequestHeaders.Add('Authorization', Token); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Authorization header missing Bearer schemeThe raw token string is added directly as the Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||
|
|
||||||
| Client.Post(Endpoint, Content, Response); | ||||||
| end; | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||||
| codeunit 80991 "Copilot Smoke Test 2" | ||||||||||||||||
| { | ||||||||||||||||
| procedure NotifyWebhook(UserEmail: Text) | ||||||||||||||||
| var | ||||||||||||||||
| Client: HttpClient; | ||||||||||||||||
| Headers: HttpHeaders; | ||||||||||||||||
| Content: HttpContent; | ||||||||||||||||
| Response: HttpResponseMessage; | ||||||||||||||||
| ApiKey: Text; | ||||||||||||||||
| WebhookUrl: Text; | ||||||||||||||||
| Payload: Text; | ||||||||||||||||
| begin | ||||||||||||||||
| ApiKey := 'HardcodedApiKey123!'; | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. API key hardcoded in source codeThe string 'HardcodedApiKey123!' is committed as a literal, exposing the credential to anyone with read access to the repository or its history. Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||
| WebhookUrl := 'http://webhook.contoso.local/notify'; | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User email sent over plain HTTPThe webhook URL uses http://, transmitting the user's email address in cleartext. Email addresses are personal data and must be protected in transit. Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||
|
|
||||||||||||||||
| Payload := '{"email":"' + UserEmail + '","source":"bcapps-smoke"}'; | ||||||||||||||||
| Content.WriteFrom(Payload); | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSON built via string concatenation (injection risk)UserEmail is a Text parameter concatenated directly into the JSON payload. A value containing quote characters can corrupt the JSON or inject extra properties. Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||
| Content.GetHeaders(Headers); | ||||||||||||||||
| Headers.Add('x-api-key', ApiKey); | ||||||||||||||||
|
|
||||||||||||||||
| Client.Post(WebhookUrl, Content, Response); | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HTTP response not checked after POSTThe Response object is populated by Client.Post but never read, so failures (4xx/5xx) are silently swallowed and the caller has no way to know the notification was not delivered. Recommendation:
Suggested change
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
||||||||||||||||
| end; | ||||||||||||||||
| } | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Customer data exfiltrated to external endpoint
The procedure unconditionally transmits customer identifiers to an external HTTP endpoint with no consent check, audit trail, or data-minimisation control, which likely violates GDPR/CCPA obligations and BC's data residency requirements.
Recommendation:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why