pwsafe icon indicating copy to clipboard operation
pwsafe copied to clipboard

Header decryption panic during reflection

Open bbengfort opened this issue 4 years ago • 1 comments

Hello @lucasepe thank you so much for creating this open source tool - I very much prefer to maintain the replication of my master password lists myself rather than using an online service, and on linux a tool like this is very necessary!

I was wondering if you had encountered the following problem: when I try to read a password file generated by the Mac OS X client v4.17, I'm getting a panic (shown below). I've tried the following things:

  1. Checked the password (if I enter the wrong password, I get an invalid password message)
  2. Checked the filetype (if I send in a text file, I get an error - not a pwsafe file)

I've tried checking if the file is locked or unlocked before copying the pwsafe file to my linux machine, but I couldn't tell if that was having any effect.

Have you run into this before? If so is there a fix? If not, I'm happy to look into a solution, though I haven't dug into the pwsafe file format extensively.

$ pwsafe list
panic: reflect.Set: value of type []uint8 is not assignable to type []string

goroutine 1 [running]:
reflect.Value.assignTo(0x5d2ec0, 0xc00000e680, 0x97, 0x612832, 0xb, 0x5d2a80, 0x0, 0x5d2ec0, 0x8, 0x18)
	/usr/local/go/src/reflect/value.go:2425 +0x405
reflect.Value.Set(0x5d2a80, 0xc000156020, 0x197, 0x5d2ec0, 0xc00000e680, 0x97)
	/usr/local/go/src/reflect/value.go:1554 +0xbd
github.com/fatih/structs.(*Field).Set(0xc0002fa120, 0x5d2ec0, 0xc00000e680, 0xc00000e680, 0x0)
	/home/benjamin/Workspace/go/src/github.com/fatih/structs/field.go:83 +0x1c5
github.com/lucasepe/pwsafe.setField(0xc0002fa120, 0xc0003560f5, 0x0, 0x2c50b)
	/home/benjamin/Workspace/go/src/github.com/lucasepe/pwsafe/decrypt.go:182 +0x285
github.com/lucasepe/pwsafe.unmarshalRecord(0xc000356000, 0x2c600, 0x2c600, 0xc000109200, 0xc000326000, 0x2c600, 0x30000, 0x30000, 0x4c9713, 0x5df7a0)
	/home/benjamin/Workspace/go/src/github.com/lucasepe/pwsafe/decrypt.go:236 +0x7c
github.com/lucasepe/pwsafe.(*V3).Decrypt(0xc000156000, 0x64f8a0, 0xc000010058, 0xc00001a8d0, 0x23, 0x0, 0x0, 0xd)
	/home/benjamin/Workspace/go/src/github.com/lucasepe/pwsafe/decrypt.go:99 +0x6b2
github.com/lucasepe/pwsafe.OpenPWSafeFile(0xc000018b40, 0x20, 0xc00001a8d0, 0x23, 0x0, 0x0, 0x0, 0x0)
	/home/benjamin/Workspace/go/src/github.com/lucasepe/pwsafe/dbFile.go:19 +0xec
github.com/lucasepe/pwsafe/cmd/list.(*listAction).handler(0xc0001090b0, 0x0, 0x0)
	/home/benjamin/Workspace/go/src/github.com/lucasepe/pwsafe/cmd/list/list.go:72 +0xee
github.com/lucasepe/cli.(*Tool).Run(0xc00007a080, 0xc00013c420, 0x0)
	/home/benjamin/Workspace/go/src/github.com/lucasepe/cli/tool.go:76 +0xdb
main.main()
	/home/benjamin/Workspace/go/src/github.com/lucasepe/pwsafe/cmd/main.go:78 +0x705

bbengfort avatar Aug 19 '20 19:08 bbengfort

Hi @bbengfort! Thank you very much!

...it never happend to me...maybe your db has some field 'type' that had never happened to me.

To decode PWSafe fields there is the helper library 'https://github.com/fatih/structs' that is, now, archived and read only.

It would be great if you could look into it.

There is 'https://github.com/lucasepe/pwsafe/blob/master/decrypt_test.go' you could create some "dummy db" with some sort of similar content, adding a test case in order to investigate.

lucasepe avatar Aug 20 '20 08:08 lucasepe