fix(#5): Import API 파일 경로 조작 공격 방어 (경계 문자 검증)
This commit is contained in:
@@ -209,8 +209,16 @@ public class ExperionDatabaseController : ControllerBase
|
||||
[HttpPost("import")]
|
||||
public async Task<IActionResult> Import([FromBody] ExperionCsvImportDto dto)
|
||||
{
|
||||
// 경계 문자 및 경로 조작 방지: 파일명에 점, 역슬래시, 슬래시, 공백 제거
|
||||
var safeFileName = dto.FileName.Trim();
|
||||
var invalidChars = new char[] { '.', '\\', '/', ' ', '\t', '\n', '\r' };
|
||||
if (string.IsNullOrEmpty(safeFileName) || invalidChars.Any(c => safeFileName.Contains(c)))
|
||||
{
|
||||
return BadRequest(new { error = "파일명에 허용되지 않는 문자가 포함되었습니다." });
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(dto.ServerHostName) &&
|
||||
dto.FileName.StartsWith(dto.ServerHostName, StringComparison.OrdinalIgnoreCase))
|
||||
safeFileName.StartsWith(dto.ServerHostName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user