- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: go-security/responsewriter-no-fprintf
Language: Go
Severity: Warning
Category: Security
CWE: 79
Using fmt.Fprintf
on a http.ResponseWriter
can potentially introduce security issues and cross-site scripting (XSS) vulnerabilities if not handled carefully. When using fmt.Fprintf
, there is a risk of inadvertently including untrusted data in the response body without properly escaping or sanitizing it. This can allow an attacker to inject malicious code into the response, which can then be executed in the context of other users accessing the page, leading to XSS attacks.
To prevent security issues and XSS vulnerabilities when writing to a http.ResponseWriter
, developers should:
html/template
package in Go to safely interpolate dynamic content into HTML templates.fmt.Fprintf
directly to write data to the response body when dealing with untrusted input. Instead, prefer using methods like WriteHeader
and Write
from http.ResponseWriter
to prevent unintended data insertion.By following these best practices and being cautious about how data is written to a http.ResponseWriter
, developers can reduce the risk of security vulnerabilities and better protect their web applications from potential XSS attacks.
func my_controller(anotherArgument myType1, responseWriter http.ResponseWriter, anotherArgument myType2) {
fmt.Fprintf(responseWriter, "foo %s", something);
}
|
|
For more information, please read the Code Analysis documentation
Identify code vulnerabilities directly in yourVS Code editor
Identify code vulnerabilities directly inJetBrains products