T05 · Unauthorized Access and Privilege Escalation
- Location
__init__.py:123- Finding
Arbitrary Local Image Disclosure Through Unrestricted Chart Paths
- Content
View full analysis
Vulnerability Details
File Location:
__init__.py, lines 123–131
Vulnerability Type: Unrestricted local file access
Risk Level: Mediumpython for img_path in chart_paths: if os.path.exists(img_path): img = Image(img_path, width=480, height=280) story.append(img) story.append(Spacer(1, 20)) else: story.append(Paragraph(f"图表文件丢失:{img_path}", normal_style)) story.append(Spacer(1, 10))Technical Analysis
The
chart_pathsparameter is controlled by the caller and is used directly to access local files. The implementation only checks whether each path exists; it does not verify that the path references a chart generated by the skill, resides in an approved directory, or is a regular non-symlink file.ReportLab attempts to open every existing path as an image and embeds compatible files in the generated PDF. Consequently, an attacker who knows or can guess the location of a readable local image can cause that file to be included in a downloadable report. Large or malformed images may also consume excessive memory or cause report generation to fail.
Attack Path
- The attacker identifies or guesses a readable local image path available to the skill process.
- The attacker supplies that absolute path or a traversal-based path in
chart_paths. os.path.exists()confirms that the file exists.Image(img_path, ...)opens the caller-selected local file.- The file is embedded in the generated PDF.
- The attacker retrieves the PDF and views the disclosed image.
Impact Assessment
Exploitation permits disclosure of ReportLab-compatible local image files readable by the skill process. It does not grant additional operating-system privileges or arbitrary access to non-image files based on the reviewed code. The disclosure scope is bounded by the process account's filesystem permissions and the image formats accepted by ReportLab ...[truncated 94 chars]
- Remediation
View remediation
Remediation Suggestions
- Store generated charts in a dedicated private directory controlled by the skill.
- Resolve each submitted path with
os.path.realpath()orpathlib.Path.resolve(). - Verify that the resolved path is a descendant of the approved chart directory.
- Require the target to be a regular file and reject symbolic links.
- Maintain server-side identifiers for generated charts instead of accepting arbitrary filesystem paths.
- Validate file signatures and allow only explicitly supported image formats.
- Enforce image dimensions and file-size limits before processing.
- Open validated files through controlled file handles where supported to reduce time-of-check/time-of-use risks.
