xeals / signal-back

Decrypt Signal encrypted backups outside the app
Apache License 2.0
704 stars 67 forks source link

panic with ParametersToPart with len(SqlStatement_SqlParameter) == 25 #56

Open dolanor opened 5 years ago

dolanor commented 5 years ago

Detailed description

Hi, I wanted to implement a signal backup reader/writer in Go, so it was a delight to see it here :) Trying to decrypt an archive from 2018-04-01, I got a panic accessing an out of range slice item. Another archive from 2018-06-18 (on another phone) was fine.

Full relevant output

$ signal-back format -v -o signal-s8.xml signal-2018-04-01-11-48-29.backup 
Password: 2019/05/24 03:25:04 Unexpected error: runtime error: index out of range
2019/05/24 03:25:04 TEMP: statement is statement:"INSERT INTO part VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" parameters:<integerParameter:1 > parameters:<integerParameter:1 > parameters:<integerParameter:0 > parameters:<stringParamter:"image/png" > parameters:<nullparameter:true > parameters:<nullparameter:true > parameters:<nullparameter:true > parameters:<nullparameter:true > parameters:<nullparameter:true > parameters:<nullparameter:true > parameters:<nullparameter:true > parameters:<nullparameter:true > parameters:<nullparameter:true > parameters:<integerParameter:0 > parameters:<stringParamter:"/data/user/0/org.thoughtcrime.securesms/app_parts/part1279258965.mms" > parameters:<integerParameter:98833 > parameters:<nullparameter:true > parameters:<stringParamter:"/data/user/0/org.thoughtcrime.securesms/app_parts/part1197476668.mms" > parameters:<doubleParameter:1 > parameters:<integerParameter:1512410589211 > parameters:<nullparameter:true > parameters:<stringParamter:"2936884363452528202" > parameters:<integerParameter:0 > parameters:<nullparameter:true > parameters:<nullparameter:true > 
2019/05/24 03:25:04 TEMP: statement is &signal.SqlStatement{Statement:(*string)(0xc00295ac60), Parameters:[]*signal.SqlStatement_SqlParameter{(*signal.SqlStatement_SqlParameter)(0xc00085a550), (*signal.SqlStatement_SqlParameter)(0xc00085a5a0), (*signal.SqlStatement_SqlParameter)(0xc00085a5f0), (*signal.SqlStatement_SqlParameter)(0xc00085a640), (*signal.SqlStatement_SqlParameter)(0xc00085a690), (*signal.SqlStatement_SqlParameter)(0xc00085a6e0), (*signal.SqlStatement_SqlParameter)(0xc00085a730), (*signal.SqlStatement_SqlParameter)(0xc00085a780), (*signal.SqlStatement_SqlParameter)(0xc00085a7d0), (*signal.SqlStatement_SqlParameter)(0xc00085a820), (*signal.SqlStatement_SqlParameter)(0xc00085a870), (*signal.SqlStatement_SqlParameter)(0xc00085a8c0), (*signal.SqlStatement_SqlParameter)(0xc00085a910), (*signal.SqlStatement_SqlParameter)(0xc00085a960), (*signal.SqlStatement_SqlParameter)(0xc00085a9b0), (*signal.SqlStatement_SqlParameter)(0xc00085aa00), (*signal.SqlStatement_SqlParameter)(0xc00085aa50), (*signal.SqlStatement_SqlParameter)(0xc00085aaa0), (*signal.SqlStatement_SqlParameter)(0xc00085aaf0), (*signal.SqlStatement_SqlParameter)(0xc00085ab40), (*signal.SqlStatement_SqlParameter)(0xc00085ab90), (*signal.SqlStatement_SqlParameter)(0xc00085abe0), (*signal.SqlStatement_SqlParameter)(0xc00085ac30), (*signal.SqlStatement_SqlParameter)(0xc00085ac80), (*signal.SqlStatement_SqlParameter)(0xc00085acd0)}, XXX_unrecognized:[]uint8(nil)}
goroutine 1 [running]:
runtime/debug.Stack(0xc0000a0000, 0x2, 0xc000959200)
    /usr/local/go/src/runtime/debug/stack.go:24 +0x9d
runtime/debug.PrintStack()
    /usr/local/go/src/runtime/debug/stack.go:16 +0x22
github.com/xeals/signal-back/cmd.XML.func2.1(0xc00281d5c0)
    /home/dolanor/go/src/github.com/xeals/signal-back/cmd/format.go:169 +0x142
panic(0x5e5820, 0x7bc940)
    /usr/local/go/src/runtime/panic.go:522 +0x1b5
github.com/xeals/signal-back/types.ParametersToPart(0xc000523c00, 0x19, 0x20, 0x47720)
    /home/dolanor/go/src/github.com/xeals/signal-back/types/raw.go:396 +0x774
github.com/xeals/signal-back/types.StatementToPart(...)
    /home/dolanor/go/src/github.com/xeals/signal-back/types/raw.go:362
github.com/xeals/signal-back/types.NewPartFromStatement(0xc00281d5c0, 0x61ce45, 0x10, 0x101, 0x9)
    /home/dolanor/go/src/github.com/xeals/signal-back/types/sms.go:313 +0x64
github.com/xeals/signal-back/cmd.XML.func2(0xc00281d5c0, 0x0, 0x0)
    /home/dolanor/go/src/github.com/xeals/signal-back/cmd/format.go:192 +0x109
github.com/xeals/signal-back/types.(*BackupFile).Consume(0xc0004ba070, 0xc000084b70, 0xc00005e230, 0xc00000e020, 0x0, 0x0)
    /home/dolanor/go/src/github.com/xeals/signal-back/types/backup.go:260 +0x14d
github.com/xeals/signal-back/cmd.XML(0xc0004ba070, 0x65c7c0, 0xc000010008, 0x3, 0x1)
    /home/dolanor/go/src/github.com/xeals/signal-back/cmd/format.go:203 +0x201
github.com/xeals/signal-back/cmd.glob..func4(0xc000092420, 0x0, 0x0)
    /home/dolanor/go/src/github.com/xeals/signal-back/cmd/format.go:70 +0x457
github.com/urfave/cli.HandleAction(0x5da720, 0x628998, 0xc000092420, 0x0, 0xc0000124e0)
    /home/dolanor/go/src/github.com/urfave/cli/app.go:501 +0xc8
github.com/urfave/cli.Command.Run(0x61ae19, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x621803, 0x1f, 0x6272b5, ...)
    /home/dolanor/go/src/github.com/urfave/cli/command.go:165 +0x487
github.com/urfave/cli.(*App).Run(0xc0000d41c0, 0xc0000121e0, 0x6, 0x6, 0x0, 0x0)
    /home/dolanor/go/src/github.com/urfave/cli/app.go:259 +0x6e3
main.main()
    /home/dolanor/go/src/github.com/xeals/signal-back/main.go:52 +0x2cf