You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Critical] Potential data loss in OCI spec Flush() - file truncated before write #2203
In internal/oci/spec_file.go, the Flush() method truncates the OCI specification file using os.Create(s.path)before writing new content via flushTo().
If the write operation fails (e.g., disk full, I/O error, permission denied), the original OCI config.json is already destroyed and cannot be recovered.
Affected File
internal/oci/spec_file.go (lines 99-111)
Current Behavior
func (sfileSpec) Flush() error {
ifs.Spec==nil {
returnfmt.Errorf("no OCI specification loaded")
}
specFile, err:=os.Create(s.path) // ← TRUNCATES FILE HERE...returnflushTo(s.Spec, specFile) // ← IF THIS FAILS, DATA IS LOST
}
### ExpectedBehaviorWritetoatemporaryfilefirst, thenperformanatomicrename/replaceonlyafterthewrite succeeds. Thispreventsdatalossifthewriteoperation fails.
### Impact-Containerruntimeconfiguration (OCIspec) canbepermanentlydestroyed-ContainersusingtheaffectedOCIspecwillfailtostart-Norecoverymechanismifthewritefailsmid-operation
### ProposedFix1.Writemodifiedspectoatemporaryfileinthesamedirectory2.Ifwritesucceeds, atomicallyrenametempfiletotargetpath3.Ifwritefails, originalfileremainsintact
### AdditionalContextThiscodepathisexecutedwhen`nvidia-container-runtime-hook`or`nvidia-container-runtime`appliesOCIspecmodificationsbeforestartingaGPUcontainer.
Activity