DAST API Crash with error message: System.NotSupportedException: Unknown body type
Summary
A client has reported that the DAST API is crashing when generating the report.
Steps to reproduce
Example Project
Relevant logs and/or screenshots
- Scan log
2021-06-07 22:42:33 [INF] API Runner: Finished testing. Performed a total of 1939 requests.
2021-06-07 22:42:35 [INF] API Security: Generating security report as 'gl-dast-api-report.json'.
2021-06-07 22:42:36 [ERR] API Security: Error communicating with API Security.
2021-06-07 22:42:36 [ERR] API Security: vvvv ERROR vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2021-06-07 22:42:36 [ERR] API Security: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2021-06-07 22:42:36 [ERR] API Security: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2021-06-07 22:42:36 [ERR] API Security: Error occurred while generating report.
/peach/analyzer-dast-api: line 84: 65 Aborted (core dumped) dotnet /peach/Peach.Web.dll &> $DAST_API_LOG_SCANNER
/peach/analyzer-dast-api: line 47: kill: (65) - No such process
- bottom of the
gl-api-security-scanner.log
22:42:35.949 [INF] <Peach.Web.Core.Services.WebApiService> Unable to decode Content-Type: application/json, falling back to text/plain
Unhandled exception. 22:42:35.951 [INF] <Peach.Web.Core.Services.WebApiService> Unable to decode Content-Type: application/json, falling back to text/plain
System.NotSupportedException: Unknown body type
at Peach.Web.Core.Services.ReportService.GetDisplayBody(Operation op) in /builds/gitlab-org/security-products/analyzers/api-fuzzing-src/web/PeachWeb/Core/Services/ReportService.cs:line 507
at Peach.Web.Core.Services.ReportService.AddActualHttpMessages(Fault fault, FaultDetailBase faultDefault, FaultData faultData, Vulnerabilities vuln) in /builds/gitlab-org/security-products/analyzers/api-fuzzing-src/web/PeachWeb/Core/Services/ReportService.cs:line 287
at Peach.Web.Core.Services.ReportService.AddVulnerability(SecurityReport report, String assetBaseUrl, Fault fault, FaultDetailBase faultDetail, FaultData faultData) in /builds/gitlab-org/security-products/analyzers/api-fuzzing-src/web/PeachWeb/Core/Services/ReportService.cs:line 220
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
22:42:35.952 [INF] <Peach.Web.Core.Services.WebApiService> Unable to decode Content-Type: application/json, falling back to text/plain
Solution
-
Quick fix. Prevent the exception from happening. Display Body unavailablewhen the exception happens. MR!520 -
Publish new container
Edited by Herber Madrigal