T09 · Insecure Skill Coding Practices
- Location
scripts/excel_parser.py:25- Finding
Unrestricted Local Workbook Access and Unbounded Excel Parsing
- Content
View full analysis
Vulnerability Details
File Location:
scripts/excel_parser.py, lines 25-32, 46-64, and 96-121
Vulnerability Type: Unrestricted file access and resource exhaustion
Risk Level: MediumVulnerable Code
python if sheet_name: df = pd.read_excel(file_path, sheet_name=sheet_name) sheets_data = {sheet_name: df} else: sheets_data = pd.read_excel(file_path, sheet_name=None)python for sheet_name, df in sheets_data.items(): sheet_info = { "name": sheet_name, "total_rows": len(df), "total_columns": len(df.columns), "columns": list(df.columns), "data": [] } for idx, row in df.iterrows(): row_dict = {} for col in df.columns: value = row[col] if pd.isna(value): row_dict[col] = None else: row_dict[col] = str(value) sheet_info["data"].append(row_dict) result["sheets"][sheet_name] = sheet_infopython args = parser.parse_args() result = parse_excel(args.file_path, args.sheet_name) if args.identify_risks and result["status"] == "success": risk_sheets = identify_risk_data(result) result["risk_sheets"] = risk_sheets result["risk_sheet_count"] = len(risk_sheets) print(json.dumps(result, ensure_ascii=False, indent=2))Technical Analysis
The
--file-pathargument is passed directly topandas.read_excel()without resolving and validating the path against an authorized upload directory. The implementation does not reject absolute paths, parent-directory traversal, or symbolic links. Consequently, the parser can access any compatible workbook readable by the operating-system account running the Skill if its path is known or can be inferred.When no sheet is specified,
sheet_name=Nonecauses pandas to load every worksheet. The parser then iterates through every row and column, ...[truncated 1728 chars]- Remediation
View remediation
Remediation Suggestions
- Resolve the supplied path with
Path.resolve()and require it to remain within a dedicated, trusted upload directory. - Reject absolute paths, parent-directory traversal, symbolic links, non-regular files, and files that were not registered as uploads for the current session.
- Allowlist supported workbook extensions and verify the file type independently of the filename.
- Enforce a maximum file size before calling pandas.
- Set limits for worksheet count, rows, columns, total cells, processing time, memory use, and serialized output size.
- Require an explicit worksheet selection for large or multi-sheet files, or inspect workbook metadata before loading worksheet contents.
- Return only the columns and rows required for risk analysis instead of emitting the entire workbook.
- Run parsing in an isolated, least-privileged worker with filesystem restrictions and resource quotas.
- Replace raw exception details returned to users with a generic error while recording diagnostic details only in protected logs.
- Resolve the supplied path with
