Tcl Source Code

View Ticket
Login
Ticket UUID: c315de9e44213d74d546088a65512ba797b8e3da
Title: Password protected zip files can be rewritten without the password
Type: Bug Created on: 2023-09-27 15:16:47
Submitter: apnadkarni Assigned to: nobody
Subsystem: - New Builtin Commands Severity: Important
Priority: 5 Medium Last modified: 2026-10-21 10:03:38
Status: Closed Closed by: nobody
Resolution: Fixed Closed on: 2023-09-29 03:35:47
Version: 8.7
Description:

Password protected files are protected from reading but not writing.

% zipfs mount ../tests/zipfiles/test-password.zip [zipfs root]
% set fd [open [file join [zipfs root] cipher.bin]]
decryption failed - no password provided
% set fd [open [file join [zipfs root] cipher.bin] w]
zipfs_14c_1
% puts $fd "new data"
% close $fd
% set fd [open [file join [zipfs root] cipher.bin]]
zipfs_0_2
% gets $fd
new data
% close $fd
User Comments:
chw added on 2023-09-27 16:31:56:
Ashok, I've taken the liberty to change the ticket title replacing modified
by rewritten. Why? Since those files can be only written from scratch. 
Modification would require prior knowledge of content which isn't given
due to not having the password for decoding the file.

Which brings us to discussion of the use(full|less)ness of being able to
non-persistently modifying mounted ZIP filesystems. When I added this
(deliberately undocumented) feature I was thinking of temporarily
monkey patching stuff, not to have it as an assured property of the
ZIP filesystem.

apnadkarni added on 2023-09-28 11:29:35:
Sure, no problem changing the title.

I'm also chewing on the usefulness of a writable zip file system which is not persisted. I feel it would have some uses but is somewhat incomplete at the moment, e.g. write size being limited at open time. Not completely crystallized in my mind as to whether to postpone to a future release or not.

Either way manpages need to be updated to either say zipfs is read-only (and change implementation accordingly) or state the limitations (no new files or directories, size limits etc.)

Still ruminating on what direction to propose ...

chw added on 2023-09-28 15:45:03:
What about booking this feature under the ::tcl::unsupported::*
category then? And indeed is the ZIPFS unwritable as long as the
magic *::wrmax isn't changed from its zero default.

apnadkarni added on 2023-09-28 16:01:13:
That's one possibility. Right now I'm focused on working through the pending bugs. Let's see where things stand after that.

apnadkarni added on 2023-09-29 03:35:47:
Fixed in [9c204498a8].

jan.nijtmans added on 2023-09-29 08:40:21:

MacOS build failure: https://github.com/tcltk/tcl/actions/runs/6348251441


apnadkarni added on 2023-09-29 12:05:47:
Disabled password related tests on MacOS.

apnadkarni added on 2023-09-30 16:34:47:
This bug is assigned to me, presumably by Jan. However, someone with Mac access and familiarity with that platform will need to pick this up. Tests run without error on Windows and Linux.

serhiy.storchaka added on 2026-10-21 10:03:38:

Fixed in 9.0.0 by [9c204498a8] (trunk: [bea92dfdc5]): encrypted members can no longer be opened for writing without the password. The macOS-only test failures are tracked in [bbe7c6ff9e].