Validate unsafe YAML object construction
Needs: The application uses an unsafe PyYAML loader that permits the selected Python object constructor
Commands
# Baseline
!!python/object/apply:os.system ["id"]
Verify → Require source/configuration evidence for the loader and an attributable effect; a .yml extension is insufficient.
If it fails → ConstructorError often indicates safe or restricted loading. Preserve that negative evidence instead of trying unrelated tags blindly. More detail ↓
Explanation & examples
Validate unsafe YAML object construction
- USE WHEN
- Source or errors identify server-side Python YAML loading of controlled content
- STARTING ACCESS
- A reproducible application request and a controlled input or access-context comparison
- RESULT
- A verified command or object-construction effect in the loader process
Recognize the clue
Inspect source/errors for the actual Python YAML loader before placing a constructor in the application's required schema.
!!python/object/apply:os.system ["id"]
Loader evidence: unsafe loader
Effect: command-specific identity outputMeans: The application constructed the selected Python object under an unsafe loader.
Confirm: Confirm loader/version and an attributable effect in the real import/request path.
- After validation
- Unsafe construction is confirmed: use only the required bounded effect.
- Ruled out in this context
- ConstructorError under safe/restricted loading rejects this constructor route.
- Still inconclusive
- A .yml extension without loader evidence leaves the condition unknown.
Troubleshooting: ConstructorError often indicates safe or restricted loading. Preserve that negative evidence instead of trying unrelated tags blindly.
Use when source or errors identify Python YAML processing with an unsafe loader and you control the loaded YAML. An ordinary JSON field or yaml.safe_load() does not supply this condition.
Put the probe in the actual YAML input/file, preserving its required surrounding structure. Read: attributable command output/effect supports unsafe construction. ConstructorError for the Python tag commonly indicates a loader that does not permit that constructor. Confirm the installed PyYAML version and loader (UnsafeLoader/unsafe load), rather than assuming that any use of YAML permits Python object execution.
Sources: upstream 1.
Why it works
YAML syntax is not itself dangerous; the selected loader and allowed constructors define the capability.
Worked example · hypothetical
Observation: an import feature loads YAML and source names an unsafe loader. Test: submit the minimal constructor in the required surrounding schema. Illustrative output: a command-specific effect appears. Interpretation: verify the process context.
New identity, privilege, host or route? Re-enumerate → All topic tasks →