Download it now!
Bug 120499 - Can't use password when (un)restricting DOC(X) forms
Summary: Can't use password when (un)restricting DOC(X) forms
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected)
Hardware: All All
: medium enhancement
Assignee: Not Assigned
Depends on:
Blocks: DOCX-ActiveX-Legacy Password-Protected DOCX-Doc-Protection DOC-Doc-Protection
  Show dependency treegraph
Reported: 2018-10-11 04:16 UTC by Aron Budea
Modified: 2020-07-25 10:38 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:

Sample DOCX (restricted using pw 1234) (16.20 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-10-11 04:16 UTC, Aron Budea
protectSection.odt: the LO way of protecting - half works in DOCX and doesn't in DOC (9.42 KB, application/vnd.oasis.opendocument.text)
2018-10-13 19:21 UTC, Justin L

Note You need to log in before you can comment on or make changes to this bug.
Description Aron Budea 2018-10-11 04:16:47 UTC
Created attachment 145585 [details]
Sample DOCX (restricted using pw 1234)

The attached DOCX was created in Word, contains a legacy form field, and has been restricted to only allow filling in forms, with a password set (which is "1234").

Writer has a compatibility setting for such forms: LibreOffice Writer -> Compatibility -> Protect form.
It's a simple check box, and doesn't ask for a password.

There should be a password prompt when enabling/disabling form protection (would be optional when enabling).
The question is, when: when the checkbox is ticket/unticked, or when the setting is applied?

I assume the setting would have a single implementation for DOC and DOCX documents, just the filter code would be different (currently exporting form protection doesn't work in DOC format, see bug 52555).

Observed using LO (425af6845ebe066c950b0b63f50563e067485f3e) / Windows 7.
Comment 1 Justin L 2018-10-13 17:38:06 UTC
Interesting note. Word 2003 unrestricts without a password too, but it properly saves a password.
Comment 2 Justin L 2018-10-13 18:41:26 UTC
DOCX: only round-trips these settings, but doesn't use them other than to turn on PROTECT_FORM.  (look for XML_documentProtection in docxexport.cxx and GetDocumentProtectionSettings() in writerfilter).

I like being able to bypass these passwords in LO, and the way to disable protection is buried pretty deep, so it hardly seems necessary.
Comment 3 Justin L 2018-10-13 19:21:08 UTC
Created attachment 145686 [details]
protectSection.odt: the LO way of protecting - half works in DOCX and doesn't in DOC

Personally, if I do decide to work on this, I would start by making sure that this ODT file exports/imports well with doc/docx.

Currently, it exports OK to both doc and docx (except that it doesn't export the password). Word 2016 can edit the unprotected section, honours the protected area, but unprotects without a password.

LO currently imports the resulting .doc file very poorly - no protection at all. Importing the resulting .docx file protects everything, not just the section.
Comment 4 Justin L 2018-10-17 12:13:06 UTC
I expect that the password will need to use functions from include/comphelper/docpasswordhelper.hxx
Comment 5 Justin L 2018-10-19 07:16:08 UTC
(In reply to Justin L from comment #3)
> Currently, it exports OK to both doc and docx (except that it doesn't export
> the password).
So, from a theoretical perspective, it would probably be a very bad thing to take the password implementation of LibreOffice and export it into .doc's lKeyDocProt password because that is very weak encryption. That would allow someone to take a confidential .odt file, export to .doc and then easily be able to crack the password.

However, that is NOT what OP was suggesting. They are only asking for the compatibility flag PROTECT_FORM to be connected to the .doc* password. This would not be a security concern. The passwords exist in the InteropGrabBag, and so could be checked, or re-written.
Comment 6 Justin L 2020-07-25 10:38:53 UTC
In 7.1, the situation for import is very good.  Both DOC and DOCX protect the first section, and both allow editing in the second section.

In neither case is the section password protected. (I created a new password, in case LO caches an MS Format compatible password as well as an ODT password, but that wasn't the case. I know that IS used in some places, like document crash recovery.)