Skip to content

LG-7014 Device Profiling on the SSN page#6694

Merged
theabrad merged 23 commits intomainfrom
lg-7014-device-profiling-ssn
Aug 12, 2022
Merged

LG-7014 Device Profiling on the SSN page#6694
theabrad merged 23 commits intomainfrom
lg-7014-device-profiling-ssn

Conversation

@theabrad
Copy link
Contributor

@theabrad theabrad commented Aug 4, 2022

Why? Updating the SSN page to enable LexisNexis ThreatMetrix device profiling in the form of a javascript embed.

@theabrad theabrad requested a review from a team August 4, 2022 18:08
changelog: Upcoming Features, Device Profiling, Add ThreatMetrix device profiling to ssn page
Comment on lines +36 to +38
def threatmetrix_session_id
SecureRandom.uuid
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we guard it with a feature flag here as well so that we don't put a session ID on the page if the flag is off?

<div class="tablet:grid-col-8">
<% if IdentityConfig.store.proofing_device_profiling_collecting_enabled %>
<% unless IdentityConfig.store.lexisnexis_threatmetrix_account_id.empty? || updating_ssn %>
<%= f.hidden_field :threatmetrix_session_id, value: threatmetrix_session_id %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For security/assurance purposes, what if we persisted this ID on the backend, in the session somewhere, instead of printing it to the page?

Comment on lines +25 to +26
'h-api.online-metrix.net',
'h.online-metrix.net',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's only add these domains if profiling is enabled?

'*.nr-data.net',
'dap.digitalgov.gov',
'*.google-analytics.com',
'h-api.online-metrix.net',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This domain will only be accessed by the backend, and doesn't need to be in CSP

Suggested change
'h-api.online-metrix.net',

'dap.digitalgov.gov',
'*.google-analytics.com',
'h-api.online-metrix.net',
'h.online-metrix.net',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I came across in testing is that when RAILS_ENV is not production, the CSP doesn't get applied.
If proofing_device_profiling_collecting_enabled is true, we should include h.online-metrix.net in CSP for non-production environments.

flow_session[:pii_from_doc][:ssn] = flow_params[:ssn]

if IdentityConfig.store.proofing_device_profiling_collecting_enabled
flow_session[:threatmetrix_session_id] = threatmetrix_session_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this overwrite the existing :threatmetrix_session_id (if the user is coming back to edit their SSN)? I think we want to hang on to the original session ID in that case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it would, yeah, which we probably want to avoid?

Comment on lines +28 to +31
if IdentityConfig.store.proofing_device_profiling_collecting_enabled
script_src << 'h.online-metrix.net'
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After talking with @zachmargolis, I realized that I gave some bad guidance here. Let's not modify CSP in all environments: We want to ensure that we are not making calls to 3rd parties outside of production / staging. Apologies!

Suggested change
if IdentityConfig.store.proofing_device_profiling_collecting_enabled
script_src << 'h.online-metrix.net'
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd still need some CSP revisions for this to work at all, wouldn't we? I would expect some script_src, connect_src, and iframe_src.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my understanding as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll need the following:

  • script_src
  • connect_src
  • child_src
  • image_src

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'll leave a followup ticket for CSP stuff)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why would image_src be needed? I follow the other ones since we have tags for script/iframe and I presume the script will make calls (therefore connect_src).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ThreatMetrix uses <img> tags as part of its profiling, loading up images sourced from h.online-metrix.net

theabrad and others added 2 commits August 4, 2022 20:55
Co-authored-by: Matt Hinz <matthinz@gmail.com>
flow_session[:pii_from_doc][:ssn] = flow_params[:ssn]

if IdentityConfig.store.proofing_device_profiling_collecting_enabled
flow_session[:threatmetrix_session_id] = threatmetrix_session_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we want this to be present in the in-person proofing flow version of the SSN step as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a very good question, I am not 100% certain, we need to confirm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update: Let's include this on all instances of the SSN page and we can add more specific feature flags if needed

end

def threatmetrix_session_id
return nil if !IdentityConfig.store.proofing_device_profiling_collecting_enabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check IdentityConfig.store.proofing_device_profiling_collecting_enabled twice (here and in the call function)?

end

def threatmetrix_session_id
return nil if !IdentityConfig.store.proofing_device_profiling_collecting_enabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, do we need to check IdentityConfig.store.proofing_device_profiling_collecting_enabled twice (here and in the call function)?

Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

flow_session[:pii_from_doc].nil?
end

def updating_ssn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's file a FIXME ticket and see if we can find a way to share code with these two SSN steps? In case we ever add a 3rd?


<% if IdentityConfig.store.proofing_device_profiling_collecting_enabled %>
<% unless IdentityConfig.store.lexisnexis_threatmetrix_org_id.empty? || updating_ssn %>
<script type="text/javascript" src="https://h.online-metrix.net/fp/tags.js?org_id=<%= IdentityConfig.store.lexisnexis_threatmetrix_org_id %>&session_id=<%= flow_session[:threatmetrix_session_id] %>">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions, maybe we can address in a follow-up PR later, but:

  • Do we need to worry about adding a nonce to this <script> tag so our CSP will allow it in prod? ex
  • What if we used our URIService.add_params helper so we don't have to manually interpolate?
Suggested change
<script type="text/javascript" src="https://h.online-metrix.net/fp/tags.js?org_id=<%= IdentityConfig.store.lexisnexis_threatmetrix_org_id %>&session_id=<%= flow_session[:threatmetrix_session_id] %>">
<script type="text/javascript" src="<%= URIService.add_params("https://h.online-metrix.net/fp/tags.js", org_id: IdentityConfig.store.lexisnexis_threatmetrix_org_id, session_id: flow_session[:threatmetrix_session_id]) %>">

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thought, we may want to turn the domain into a config value but that's not needed right now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a follow up ticket for these.

aduth
aduth previously requested changes Aug 11, 2022
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we address the comment at #6694 (comment) ?

@aduth aduth dismissed their stale review August 11, 2022 12:43

Avoid blocking

Idv::Flows::InPersonFlow.new(controller, {}, 'idv/in_person').tap do |flow|
flow.flow_session = {
pii_from_user: {},
threatmetrix_session_id: threatmetrix_session_id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this sets the session id... then what does the assertion check below? should we leave it blank here to make sure it gets assigned/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants