Skip to content

Commit e822af8

Browse files
committed
Prevent VIN spoofing in connectivity records
The connectivity arm of applyProtoRecordTransforms did not overwrite the payload's VIN with the authenticated (cert-derived) VIN, unlike the V, alerts, and errors arms. A vehicle with a valid client cert could submit a VehicleConnectivity payload wiith an arbitrary VIN that propagated to all backends. Stamp record.Vin to the message and add a regression test.
1 parent 20df968 commit e822af8

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

telemetry/record.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ func (record *Record) applyProtoRecordTransforms() error {
190190
if err != nil {
191191
return err
192192
}
193+
message.Vin = record.Vin
193194
record.PayloadBytes, err = proto.Marshal(message)
194195
record.protoMessage = message
195196
return err

telemetry/record_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,40 @@ var _ = Describe("Socket handler test", func() {
311311
}),
312312
)
313313

314+
It("overwrites a spoofed connectivity body VIN with the authenticated cert VIN", func() {
315+
const certVin = "certVin"
316+
const spoofedVin = "spoofedVin"
317+
payloadBytes, err := proto.Marshal(&protos.VehicleConnectivity{Vin: spoofedVin})
318+
Expect(err).NotTo(HaveOccurred())
319+
320+
message := messages.StreamMessage{
321+
TXID: []byte("1234"),
322+
DeviceID: []byte(certVin),
323+
SenderID: []byte(fmt.Sprintf("vehicle_device.%s", certVin)),
324+
MessageTopic: []byte("connectivity"),
325+
Payload: payloadBytes,
326+
}
327+
recordMsg, err := message.ToBytes()
328+
Expect(err).NotTo(HaveOccurred())
329+
330+
serializer = telemetry.NewBinarySerializer(
331+
&telemetry.RequestIdentity{
332+
DeviceID: certVin,
333+
SenderID: fmt.Sprintf("vehicle_device.%s", certVin),
334+
},
335+
map[string][]telemetry.Producer{"D4": nil},
336+
logger,
337+
)
338+
339+
record, err := telemetry.NewRecord(serializer, recordMsg, "1", true)
340+
Expect(err).NotTo(HaveOccurred())
341+
342+
output, ok := record.GetProtoMessage().(*protos.VehicleConnectivity)
343+
Expect(ok).To(BeTrue())
344+
Expect(output.GetVin()).To(Equal(certVin))
345+
Expect(output.GetVin()).NotTo(Equal(spoofedVin))
346+
})
347+
314348
It("json payload returns valid data when transmitDecodedRecords is false", func() {
315349
message := messages.StreamMessage{TXID: []byte("1234"), SenderID: []byte("vehicle_device.42"), MessageTopic: []byte("V"), Payload: generatePayload("cybertruck", "42", nil)}
316350
recordMsg, err := message.ToBytes()

0 commit comments

Comments
 (0)