Skip to content

Commit c8cdc45

Browse files
idoubiclaude
andcommitted
fix(security): block identity file access in apply_patch read/write
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ee806d8 commit c8cdc45

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

internal/agent/tools/apply_patch.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ type applyPatchArgs struct {
490490
// -----------------------------------------------------------------------------
491491

492492
func (r *Registry) readForPatch(ctx context.Context, path string) (string, error) {
493+
if r.identityFileBlocked(path) {
494+
return "", fmt.Errorf("%s", IdentityFileRefusal)
495+
}
493496
if r.workspaceStore != nil && r.agentID != "" && r.isWorkspacePath(path) {
494497
rc, err := r.workspaceStore.Get(ctx, r.agentID, r.projectID, r.sessionID, path)
495498
if err != nil {
@@ -530,6 +533,9 @@ func (r *Registry) readForPatch(ctx context.Context, path string) (string, error
530533
}
531534

532535
func (r *Registry) writeForPatch(ctx context.Context, path, content string) error {
536+
if r.identityFileBlocked(path) {
537+
return fmt.Errorf("%s", IdentityFileRefusal)
538+
}
533539
if r.workspaceStore != nil && r.agentID != "" && r.isWorkspacePath(path) {
534540
return r.workspaceStore.Put(ctx, r.agentID, r.projectID, r.sessionID, path,
535541
strings.NewReader(content), int64(len(content)), "")

0 commit comments

Comments
 (0)