Skip to content

Commit 5c6e7fd

Browse files
author
Alexander Geist
committed
prevent rest deserialization of critical data
1 parent 075881d commit 5c6e7fd

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

multibanking-encrypted/src/main/java/org/adorsys/psd2/hbci/service/HbciService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public HbciService(EncryptionService encryptionService) {
3838
@ApiResponse(code = 400, message = "Bad request", responseHeaders=@ResponseHeader(name="ERROR_KEY", description="BAD_REQUEST"))})
3939
public EncryptedListOfHbciBankAccounts loadBankAccounts(@ApiParam(value="The encrypted bank access object") EncryptedHbciLoadAccountRequest encryptedRequest) {
4040
HbciLoadAccountsRequest request = encryptionService.decrypt(encryptedRequest.getJweString(), HbciLoadAccountsRequest.class);
41-
List<BankAccount> bancAccountList = onlineBankingService.loadBankAccounts(request.getBankAccess(), request.getPin());
41+
List<BankAccount> bancAccountList = onlineBankingService.loadBankAccounts(null, request.getBankAccess(), request.getPin());
4242

4343
String encryptedJwe = encryptionService.encrypt(bancAccountList, request);
4444
EncryptedListOfHbciBankAccounts resp = new EncryptedListOfHbciBankAccounts();
@@ -51,7 +51,7 @@ public EncryptedListOfHbciBankAccounts loadBankAccounts(@ApiParam(value="The enc
5151
@ApiResponse(code = 400, message = "Bad request", responseHeaders=@ResponseHeader(name="ERROR_KEY", description="BAD_REQUEST"))})
5252
public EncryptedListOfHbciBookings loadPostings(@ApiParam(value="The encrypted bank access object") EncryptedHbciLoadBookingsRequest encryptedRequest) {
5353
HbciLoadBookingsRequest request = encryptionService.decrypt(encryptedRequest.getJweString(), HbciLoadBookingsRequest.class);
54-
List<Booking> bookingList = onlineBankingService.loadBookings(request.getBankAccess(), request.getBankAccount(), request.getPin());
54+
List<Booking> bookingList = onlineBankingService.loadBookings(null, request.getBankAccess(), request.getBankAccount(), request.getPin());
5555

5656
String encryptedJwe = encryptionService.encrypt(bookingList, request);
5757
EncryptedListOfHbciBookings resp = new EncryptedListOfHbciBookings();

multibanking-persistence/src/main/java/de/adorsys/multibanking/domain/BankAccessEntity.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package de.adorsys.multibanking.domain;
22

3+
import com.fasterxml.jackson.annotation.JsonIgnore;
34
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.core.JsonProcessingException;
6+
import com.fasterxml.jackson.databind.ObjectMapper;
47
import de.adorsys.multibanking.encrypt.Encrypted;
58
import domain.BankAccess;
69
import lombok.Data;
@@ -11,12 +14,14 @@
1114
import org.springframework.data.mongodb.core.index.Indexed;
1215
import org.springframework.data.mongodb.core.mapping.Document;
1316

17+
import java.io.IOException;
18+
1419
/**
1520
* Created by alexg on 07.02.17.
1621
*/
1722
@Data
1823
@Document
19-
@JsonIgnoreProperties({"getPassportState", "getPin"})
24+
@JsonIgnoreProperties(value = {"pin", "passportState", "externalIdMap"}, allowSetters = true)
2025
@Encrypted(exclude = {"_id", "userId"})
2126
public class BankAccessEntity extends BankAccess {
2227

@@ -30,4 +35,30 @@ public BankAccessEntity id(String id) {
3035
this.id = id;
3136
return this;
3237
}
38+
39+
public static void main(String[] args) {
40+
ObjectMapper mapper = new ObjectMapper();
41+
42+
BankAccessEntity bankAccessEntity = new BankAccessEntity();
43+
bankAccessEntity.setPin("pin12345");
44+
bankAccessEntity.setUserId("userasdfasdf");
45+
46+
try {
47+
System.out.println(mapper.writeValueAsString(bankAccessEntity));
48+
} catch (JsonProcessingException e) {
49+
// TODO Auto-generated catch block
50+
e.printStackTrace();
51+
}
52+
53+
String jsonString = "{ \"pin\":\"pin12345\",\"userId\":\"userasdfasdf\" }";
54+
try {
55+
bankAccessEntity = mapper.readValue(jsonString, BankAccessEntity.class);
56+
57+
System.out.println(bankAccessEntity.getPin());
58+
} catch (IOException e) {
59+
// TODO Auto-generated catch block
60+
e.printStackTrace();
61+
}
62+
63+
}
3364
}

multibanking-persistence/src/main/java/de/adorsys/multibanking/domain/BookingEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@CompoundIndex(name = "booking_index", def = "{'userId': 1, 'accountId': 1}"),
1919
@CompoundIndex(name = "booking_unique_index", def = "{'externalId': 1, 'accountId': 1}", unique = true)
2020
})
21-
@Encrypted(exclude = {"_id", "accountId", "externalId", "userId", "valutaDate", "bookingDate"})
21+
@Encrypted(exclude = {"_id", "accountId", "externalId", "userId", "valutaDate", "bookingDate", "bankApi"})
2222
public class BookingEntity extends Booking {
2323

2424
@Id

multibanking-persistence/src/main/java/de/adorsys/multibanking/repository/BookingRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.adorsys.multibanking.repository;
22

33
import de.adorsys.multibanking.domain.BookingEntity;
4+
import domain.BankApi;
45
import org.springframework.data.mongodb.repository.MongoRepository;
56
import org.springframework.stereotype.Repository;
67

@@ -13,7 +14,7 @@
1314
@Repository
1415
public interface BookingRepository extends MongoRepository<BookingEntity, String> {
1516

16-
List<BookingEntity> findByUserIdAndAccountId(String userId, String bankAccountId);
17+
List<BookingEntity> findByUserIdAndAccountIdAndBankApi(String userId, String bankAccountId, BankApi bankApi);
1718

1819
Optional<BookingEntity> findByUserIdAndId(String userId, String bookingId);
1920

0 commit comments

Comments
 (0)