secure views Flashcards

(15 cards)

1
Q

What is a secure view in Snowflake?

A

A secure view ensures that users cannot indirectly access underlying base table data through optimizer shortcuts or by inspecting the view definition. It provides stronger privacy and security guarantees than a regular view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why might a non-secure view expose hidden data?

A

Some internal optimizations for non-secure views may access underlying data, which could allow users to infer or access data that should be hidden using user-defined functions or clever queries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is a secure view’s definition protected?

A

A secure view’s query definition is only visible to authorized users with the appropriate roles. Unauthorized users cannot see the SQL text through commands like SHOW VIEWS or GET_DDL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When should you use a secure view in Snowflake?

A

Use secure views when you need to limit access to sensitive data and ensure that users cannot infer or access underlying base table details. They should not be used for simple convenience views because secure views can have performance trade-offs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an example of data inference through a non-secure view?

A

A user could use a query like SELECT * FROM widgets_view WHERE 1/iff(color = 'Purple', 0, 1) = 1; to trigger a division-by-zero error if hidden ‘Purple’ data exists, indirectly exposing its existence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does the SECURE keyword work when creating a view?

A

Add the SECURE keyword to the CREATE VIEW or CREATE MATERIALIZED VIEW statement. You can also convert a view to secure using ALTER VIEW to set or unset the SECURE property.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do secure views interact with the Query Profile?

A

The internal logic and query plan of a secure view are not exposed in the Query Profile, even to the owner, to prevent indirect data exposure through profiling details.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can you check if a view is secure?

A

Use the IS_SECURE column in INFORMATION_SCHEMA or ACCOUNT_USAGE views, or run SHOW VIEWS or SHOW MATERIALIZED VIEWS to check the secure status of a view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can roles and secure views be used together for row-level security?

A

You can use functions like CURRENT_ROLE() or CURRENT_USER() in a secure view’s WHERE clause to filter rows dynamically based on the user’s role, preventing unauthorized access to rows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a best practice when using sequence-generated keys with secure views?

A

Avoid exposing sequence-generated IDs because users could deduce information about the data distribution. Use UUIDs or obfuscate the values to prevent inference.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does Snowflake protect scanned data size for secure views?

A

Snowflake does not expose data scanned metrics for secure views to prevent indirect insights about underlying data volumes, though query performance might still offer rough hints.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a stronger alternative to using secure views for extreme security?

A

Instead of using a view, create separate physical tables for each user or role containing only the accessible data. This avoids all inference risks but increases management complexity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Can you use secure views with Secure Data Sharing?

A

Yes, but when using CURRENT_ROLE or CURRENT_USER in a secure view shared to another account, these functions return NULL because the provider does not control the consumer’s roles or users.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can you view secure view definitions when needed?

A

Authorized users with the owning role can view secure view definitions. Users with the ACCOUNTADMIN role or SNOWFLAKE.OBJECT_VIEWER database role can also access secure view details via ACCOUNT_USAGE views.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why shouldn’t secure views be used just for convenience?

A

Secure views come with performance trade-offs because they skip certain optimizations. Use them specifically for protecting sensitive data, not for simplifying queries that don’t require extra security.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly